Compare commits

...

2 Commits

8 changed files with 104 additions and 10 deletions

View File

@@ -1,5 +1,18 @@
# Changelog # Changelog
## 0.5.3 - 2026-06-14
- Verhindert fachlich falsche Sensorzuordnungen nur aufgrund generischer Namen wie
`Licht` oder `Lichtschalter`
- Übernimmt numerische Sensoren nur noch bei einem belastbaren absoluten Score und
einer eindeutigen Abgrenzung zum zweitbesten Kandidaten
- Begrenzt Zusatzkontext auf relevante Sensoren und bevorzugt bei Lichtaktoren
echte Beleuchtungsstärke gegenüber fremden Leistungs- oder Energiezählern
## 0.5.2 - 2026-06-14
- Add-on-Build invalidiert den Docker-Cache bei jeder Versionsänderung, damit
Versionsmetadaten und tatsächlich ausgelieferter Anwendungscode übereinstimmen
- Korrigierte Ingress-Oberfläche aus 0.5.1 dadurch erstmals zuverlässig ausgeliefert
## 0.5.1 - 2026-06-14 ## 0.5.1 - 2026-06-14
- Technische Modell-, Intervall- und Sicherheitsparameter aus der normalen - Technische Modell-, Intervall- und Sicherheitsparameter aus der normalen
Home-Assistant-Add-on-Konfiguration entfernt; sichere Standardwerte bleiben aktiv Home-Assistant-Add-on-Konfiguration entfernt; sichere Standardwerte bleiben aktiv

View File

@@ -4,13 +4,17 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 PIP_NO_CACHE_DIR=1
# The add-on version changes for every release. Copying its config before the
# clone makes Docker invalidate the application layer instead of reusing old code.
COPY config.yaml /tmp/addon-config.yaml
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends git \ && apt-get install -y --no-install-recommends git \
&& git clone --depth 1 --branch main \ && git clone --depth 1 --branch main \
http://192.168.6.31:3000/pino/sillyhome-next.git /app \ http://192.168.6.31:3000/pino/sillyhome-next.git /app \
&& python -m pip install --upgrade pip \ && python -m pip install --upgrade pip \
&& python -m pip install /app \ && python -m pip install /app \
&& rm -rf /var/lib/apt/lists/* /app/.git && rm -rf /var/lib/apt/lists/* /app/.git /tmp/addon-config.yaml
COPY run.sh /run.sh COPY run.sh /run.sh
RUN chmod 0755 /run.sh RUN chmod 0755 /run.sh

View File

@@ -1,5 +1,5 @@
name: SillyHome Next name: SillyHome Next
version: "0.5.1" version: "0.5.3"
slug: sillyhome_next slug: sillyhome_next
description: Lernt automatisch aus deinem Verhalten und steuert freigegebene Aktoren description: Lernt automatisch aus deinem Verhalten und steuert freigegebene Aktoren
url: http://192.168.6.31:3000/pino/sillyhome-next url: http://192.168.6.31:3000/pino/sillyhome-next

View File

@@ -45,6 +45,8 @@ _STOPWORDS = frozenset(
"humidity", "humidity",
"illuminance", "illuminance",
"light", "light",
"licht",
"lichtschalter",
"power", "power",
"sensor", "sensor",
"state", "state",
@@ -54,8 +56,10 @@ _STOPWORDS = frozenset(
} }
) )
_NUMERIC_AUTO_ACCEPT_SCORE = 0.82 _NUMERIC_AUTO_ACCEPT_SCORE = 0.82
_NUMERIC_AUTO_ACCEPT_MIN_SCORE = 0.5
_NUMERIC_MIN_MARGIN = 0.18 _NUMERIC_MIN_MARGIN = 0.18
_CONTEXT_AUTO_ACCEPT_SCORE = 0.78 _CONTEXT_AUTO_ACCEPT_SCORE = 0.78
_CONTEXT_AUTO_ACCEPT_MIN_SCORE = 0.3
_MAX_CONTEXT_SELECTIONS = 5 _MAX_CONTEXT_SELECTIONS = 5
_AUDIT_LIMIT = 20 _AUDIT_LIMIT = 20
@@ -231,10 +235,14 @@ class ActuatorReconciliationService:
numeric_candidates: list[AssignmentCandidate], numeric_candidates: list[AssignmentCandidate],
context_candidates: list[AssignmentCandidate], context_candidates: list[AssignmentCandidate],
) -> AssignmentSelection: ) -> AssignmentSelection:
top_numeric = numeric_candidates[0] if numeric_candidates else None top_numeric = next(
(candidate for candidate in numeric_candidates if candidate.auto_accepted),
None,
)
top_contexts = [ top_contexts = [
candidate.entity_id candidate.entity_id
for candidate in context_candidates for candidate in context_candidates
if candidate.auto_accepted
][: _MAX_CONTEXT_SELECTIONS] ][: _MAX_CONTEXT_SELECTIONS]
if top_numeric is None: if top_numeric is None:
return AssignmentSelection( return AssignmentSelection(
@@ -433,8 +441,15 @@ class ActuatorReconciliationService:
confidence = candidate.score / highest if highest else 0.0 confidence = candidate.score / highest if highest else 0.0
margin = candidate.score - second_score if index == 0 else 0.0 margin = candidate.score - second_score if index == 0 else 0.0
auto_score = _CONTEXT_AUTO_ACCEPT_SCORE if context else _NUMERIC_AUTO_ACCEPT_SCORE auto_score = _CONTEXT_AUTO_ACCEPT_SCORE if context else _NUMERIC_AUTO_ACCEPT_SCORE
auto_accepted = confidence >= auto_score and ( minimum_score = (
context or margin >= _NUMERIC_MIN_MARGIN _CONTEXT_AUTO_ACCEPT_MIN_SCORE
if context
else _NUMERIC_AUTO_ACCEPT_MIN_SCORE
)
auto_accepted = (
candidate.score >= minimum_score
and confidence >= auto_score
and (context or margin >= _NUMERIC_MIN_MARGIN)
) )
sorted_candidates[index] = candidate.model_copy( sorted_candidates[index] = candidate.model_copy(
update={ update={
@@ -510,6 +525,9 @@ def _score_candidate(
if entity.device_class in preferred_device_classes: if entity.device_class in preferred_device_classes:
score += 0.2 score += 0.2
evidence.append(f"Passende device_class: {entity.device_class}") evidence.append(f"Passende device_class: {entity.device_class}")
if not context and actuator.domain == "light" and entity.device_class == "illuminance":
score += 0.2
evidence.append("Beleuchtungsstärke wird für Lichtaktoren bevorzugt.")
if not context and entity.unit_of_measurement is not None: if not context and entity.unit_of_measurement is not None:
score += 0.05 score += 0.05
evidence.append(f"Numerische Einheit vorhanden: {entity.unit_of_measurement}") evidence.append(f"Numerische Einheit vorhanden: {entity.unit_of_measurement}")

View File

@@ -77,7 +77,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
app = FastAPI( app = FastAPI(
title="SillyHome Next API", title="SillyHome Next API",
description="Lokales Smart-Home-Intelligenzsystem für Home Assistant.", description="Lokales Smart-Home-Intelligenzsystem für Home Assistant.",
version="0.5.1", version="0.5.2",
lifespan=lifespan, lifespan=lifespan,
) )
app.state.settings = load_settings() app.state.settings = load_settings()

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "sillyhome-next" name = "sillyhome-next"
version = "0.5.1" version = "0.5.2"
description = "Lokales Smart-Home-Intelligenzsystem für Home Assistant" description = "Lokales Smart-Home-Intelligenzsystem für Home Assistant"
requires-python = ">=3.11" requires-python = ">=3.11"
dependencies = [ dependencies = [

View File

@@ -141,7 +141,7 @@ def test_reconciliation_auto_assigns_and_trains_numeric_model(tmp_path: Path) ->
assert "binary_sensor.abstellkammer_motion" not in artifact.supported_sensors assert "binary_sensor.abstellkammer_motion" not in artifact.supported_sensors
def test_reconciliation_uses_best_automatic_mapping_when_ambiguous(tmp_path: Path) -> None: def test_reconciliation_rejects_ambiguous_numeric_mapping(tmp_path: Path) -> None:
start = datetime(2026, 6, 1, tzinfo=timezone.utc) start = datetime(2026, 6, 1, tzinfo=timezone.utc)
entities = [ entities = [
HaEntitySummary( HaEntitySummary(
@@ -181,8 +181,59 @@ def test_reconciliation_uses_best_automatic_mapping_when_ambiguous(tmp_path: Pat
record = service.configure_actuator("switch.garage_pump") record = service.configure_actuator("switch.garage_pump")
assert record.assignment.review_required is True assert record.assignment.review_required is True
assert record.assignment.selected_numeric_entity_id == "sensor.garage_energy" assert record.assignment.selected_numeric_entity_id is None
assert record.lifecycle.status is LifecycleStatus.TRAINED assert record.lifecycle.status is LifecycleStatus.ARCHIVED
def test_reconciliation_does_not_cross_assign_other_room_light_energy(
tmp_path: Path,
) -> None:
start = datetime(2026, 6, 1, tzinfo=timezone.utc)
entities = [
HaEntitySummary(
entity_id=(
"light.lichtschalter_abstellraum_"
"lichtschalter_abstellraum_s1"
),
domain="light",
friendly_name="Licht Abstellraum",
),
HaEntitySummary(
entity_id="sensor.licht_badezimmer_energy",
domain="sensor",
device_class="energy",
state_class="total_increasing",
unit_of_measurement="kWh",
friendly_name="Lichtschalter_Badezimmer Licht Badezimmer energy",
),
HaEntitySummary(
entity_id="binary_sensor.abstellraum_ture",
domain="binary_sensor",
device_class="door",
friendly_name="Abstellraum Türe",
),
HaEntitySummary(
entity_id="binary_sensor.briefkasten_open",
domain="binary_sensor",
device_class="opening",
friendly_name="Briefkasten open",
),
]
service = _service(
tmp_path,
entities,
{"sensor.licht_badezimmer_energy": _points(8, start, 1.0)},
)
record = service.configure_actuator(
"light.lichtschalter_abstellraum_lichtschalter_abstellraum_s1"
)
assert record.assignment.selected_numeric_entity_id is None
assert record.assignment.selected_context_entity_ids == [
"binary_sensor.abstellraum_ture"
]
assert record.lifecycle.status is LifecycleStatus.ARCHIVED
def test_legacy_manual_override_is_cleared_and_automatic_mapping_wins(tmp_path: Path) -> None: def test_legacy_manual_override_is_cleared_and_automatic_mapping_wins(tmp_path: Path) -> None:

View File

@@ -8,3 +8,11 @@ def test_addon_does_not_expose_internal_learning_parameters() -> None:
assert "\nschema:" not in config assert "\nschema:" not in config
assert "prediction_confidence" not in config assert "prediction_confidence" not in config
assert "execution_cooldown_seconds" not in config assert "execution_cooldown_seconds" not in config
def test_addon_version_invalidates_application_build_layer() -> None:
dockerfile = Path("addon/Dockerfile").read_text(encoding="utf-8")
config_copy = dockerfile.index("COPY config.yaml /tmp/addon-config.yaml")
repository_clone = dockerfile.index("git clone --depth 1 --branch main")
assert config_copy < repository_clone