Keep unknown window states from passing as closed
Confirmed: when an open window's contact sensor became unknown or unavailable, the tracker ended the ventilation event as a close at the poll time, started recovery at full weight and forecasts assumed the window closed. (Learning was already excluded for that zone.) Each window is now OPEN, CLOSED or UNKNOWN with its last known state, since when, and since when it is unknown: - an unknown sensor keeps an open window's event (and the zone's "open" status) going; forecasts use the last known state; - a close observed only after an outage is recorded as unconfirmed: closed=None with the reported time and a maximum duration; recovery is assumed from that report but not used for any learning; - opening seen only after an outage starts an event without a temperature-before, so its recovery is not learned either; - events count minutes with an unknown sensor; Status shows each window's last known state and unknown minutes; - one unknown sensor only blocks learning for its own zone. Predictions with an unavailable wind sensor now keep an open window's natural ventilation (calm air) instead of dropping the term; learning still refuses unknown inputs. Regression tests for every OPEN/CLOSED/UNKNOWN transition, a six-hour outage, multiple windows with one unknown, and missing wind during ventilation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17dbe76223
commit
2bddc74d37
6 files changed
+236
-34
No files matched your search
@@ -18,7 +18,7 @@ from typing import Any, Callable, Mapping
|
||||
from .const import READY_OFF_SAMPLES, READY_ON_SAMPLES, READY_SAMPLES
|
||||
from .learning import FeatureLearner
|
||||
from .physics import Learner
|
||||
from .windows import ventilation_vector
|
||||
from .windows import ventilation_vector_for_prediction
|
||||
|
||||
BASE_FEATURES = ["loss", "heat", "bias"]
|
||||
|
||||
@@ -86,7 +86,7 @@ class ZoneModel:
|
||||
ventilation = inputs.get("ventilation")
|
||||
if self.ventilation is None or not ventilation:
|
||||
return 0.0
|
||||
x = ventilation_vector(self.ventilation.features, temp, inputs["outside"], ventilation)
|
||||
x = ventilation_vector_for_prediction(self.ventilation.features, temp, inputs["outside"], ventilation)
|
||||
return self.ventilation.predict(x) if x is not None else 0.0
|
||||
|
||||
def delta(self, temp: float, inputs: Mapping[str, Any]) -> float:
|
||||
@@ -98,7 +98,7 @@ class ZoneModel:
|
||||
terms = self._main_contributions(temp, inputs)
|
||||
ventilation = inputs.get("ventilation")
|
||||
if self.ventilation is not None and ventilation:
|
||||
x = ventilation_vector(self.ventilation.features, temp, inputs["outside"], ventilation)
|
||||
x = ventilation_vector_for_prediction(self.ventilation.features, temp, inputs["outside"], ventilation)
|
||||
if x is not None:
|
||||
for name, theta, value in zip(self.ventilation.features, self.ventilation.theta, x):
|
||||
group = "recovery" if name == "recovery" else "ventilation"
|
||||
|
||||
Reference in new issue
Block a user