Recalibrate only the model parts whose configuration changed
Confirmed: learned models were matched only by zone key, so replacing a zone's sensors, changing sensor weights, moving or replacing a heat source or turning a window kept coefficients learned for a different configuration, silently. compatibility.py fingerprints exactly what each learned component depends on: the zone measurement (sensors and relative weights; equal scaling changes nothing), each zone's heat sources, the neighbour's measurement, the zone's windows, window orientation (direction term only), the recovery time (recovery only) and other zones' openings (cross term only). Comfort weight, target offset and names are not included. Heat-source baselines have their own fingerprint (sensor and included sources). On restore, a changed measurement recalibrates the zone: base and extended loss/heat/bias keep their values as a warm start, but their uncertainty, counts and readiness start over, other terms return to the prior, and the zone's forecast statistics are dropped. Otherwise only the changed terms are reset; everything else, including other zones, is kept. Each recalibration is logged (Status model_changes, info log) and saved at once. Data from before fingerprints (0.4.0) is assumed to match its current configuration and is fingerprinted at the first start, so the next edit is detected even before a learned sample. Tests cover comfort changes, sensor replacement and weights, window orientation and size, moved and replaced heat sources, re-added zones, 0.4.0 data and a second restart, plus an HA Core test through real subentry updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9bb64e79ca
commit
099c63cd02
10 files changed
+475
-25
No files matched your search
@@ -174,6 +174,14 @@ class ForecastEvaluator:
|
||||
"rooms": {room: _stats(values) for room, values in per_room.items()}}
|
||||
return result
|
||||
|
||||
def forget(self, room: str) -> None:
|
||||
"""Drop a zone's statistics, for example when its temperature is measured differently."""
|
||||
for by_horizon in self._days.values():
|
||||
for by_room in by_horizon.values():
|
||||
by_room.pop(room, None)
|
||||
for poll in self._history:
|
||||
poll["temps"].pop(room, None)
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
# Rounded copy: shorter JSON on every save; in-memory sums stay exact.
|
||||
return {"days": {day: {horizon: {room: [v[0], *(round(x, 6) for x in v[1:])]
|
||||
|
||||
Reference in new issue
Block a user