Heated environment: a thermostat member in the forecast ensemble

A room held at a setpoint is a different process from one left to drift. It is
a closed loop, and persistence, the baseline everything here is scored against,
is the wrong statement about it: the truth is not that it stays where it is, it
is that it returns to the setpoint.

So site.heating adds a fourth ensemble member, first order because that is what
a controlled system is:

    dT_set(h) = (T_set - T_now) * (1 - exp(-h / tau))

Humidity follows and is the part that is easy to get wrong. Heating adds no
moisture, so vapour pressure is conserved and not relative humidity:

    RH(h) = RH_now * es(T_now) / es(T_now + dT_set(h))

Warm the air and RH falls although nothing was dried, which is why a heated
house in winter is dry. The test asserts the dew point is unchanged to 1e-6.
Pressure gets zero: a thermostat cannot move the synoptic field.

Offered, not imposed. Hedge scores this member on realised error like any
other, so a wrong tau or a stale setpoint costs accuracy and gets down-weighted
rather than quietly biasing every forecast. Verified: on history with no
heating the ensemble assigned it weight 0.000. With heating off it returns zero
and is identical to persistence.

Going from three members to four means old saved heads must migrate.
from_dict reinitialises weights and member_mae. I missed member_mae first time
and it did not fail on load, it failed later inside learn() on a broadcast
error, which is a much worse place to find out; the migration test now covers
both and calls learn() to prove it.

Settings tab gains the toggle, setpoint and time constant. Turning heating on
or off is treated as a regime change like a door: discontinuity marker plus a
queued retrain.
This commit is contained in:
2026-08-16 16:39:54 +01:00
parent 498b3f6e38
commit 4cca40388f
8 changed files with 268 additions and 14 deletions
+24
View File
@@ -136,6 +136,9 @@ class SettingsIn(BaseModel):
altitude_m: Optional[float] = Field(None, ge=-430, le=9000)
latitude: Optional[float] = Field(None, ge=-90, le=90)
longitude: Optional[float] = Field(None, ge=-180, le=180)
heating: Optional[bool] = None
heating_setpoint_c: Optional[float] = Field(None, ge=5, le=35)
thermal_time_constant_h: Optional[float] = Field(None, ge=0.1, le=24)
hum_psychrometric: Optional[bool] = None
led_enabled: Optional[bool] = None
led_fps: Optional[float] = Field(None, ge=4, le=30)
@@ -647,6 +650,9 @@ def get_settings() -> Dict:
"latitude": CONFIG.site.latitude,
"longitude": CONFIG.site.longitude,
"timezone": CONFIG.site.timezone,
"heating": CONFIG.site.heating,
"heating_setpoint_c": CONFIG.site.heating_setpoint_c,
"thermal_time_constant_h": CONFIG.site.thermal_time_constant_h,
"name": CONFIG.site.name},
"sensor": {"hum_psychrometric": CONFIG.sensor.hum_psychrometric,
"cpu_heat_k": round(st.tracker.compensator.k, 4),
@@ -693,6 +699,24 @@ def post_settings(body: SettingsIn) -> Dict:
# history is now inconsistent with the new value until re-derived.
needs_recompute = needs_recompute or name == "altitude_m"
# Turning the thermostat model on or off changes which process the heads are
# fitting, so it is a regime change and gets the same treatment as a door.
if body.heating is not None and body.heating != CONFIG.site.heating:
CONFIG.site.heating = bool(body.heating)
patch.setdefault("site", {})["heating"] = bool(body.heating)
applied.append(f"heating {'on' if body.heating else 'off'}")
st.store.log_event("discontinuity", "warn",
f"heating {'on' if body.heating else 'off'}")
st.monitor.retrain_requested = True
for name, value, label in (
("heating_setpoint_c", body.heating_setpoint_c, "setpoint"),
("thermal_time_constant_h", body.thermal_time_constant_h, "time constant")):
if value is not None and value != getattr(CONFIG.site, name):
applied.append(f"{label} {getattr(CONFIG.site, name)} -> {value}")
setattr(CONFIG.site, name, float(value))
patch.setdefault("site", {})[name] = float(value)
if body.hum_psychrometric is not None and \
body.hum_psychrometric != CONFIG.sensor.hum_psychrometric:
CONFIG.sensor.hum_psychrometric = bool(body.hum_psychrometric)