Readout scene, environment regime tracking, and a Kalman cadence bug in recompute

recompute replayed the Kalman over stored rows at their own spacing while q
stays tuned for the live 2 s cadence. Q scales with dt^3, so at the 30 s
persist interval the process noise was 3375x too large and the filter tracked
noise instead of smoothing: it wrote indoor temperature rates of +/-20 C/h into
the history. This is the exact trap DESIGN.md section 2 documents for
simulate.py, which does scale q, and I walked into it anyway. Now rescaled per
step, because tiering means the stored cadence is not constant. Mean |rate| on
the real board dropped to 2.73 C/h; what remains above 10 is the filter's
warm-up transient in the first four samples, which is honest.

Readout scene puts the actual numbers between the animations: temperature,
humidity, sea-level pressure and the signed three hour forecast, each in its
channel colour, scrolling. Text is drawn whole-pixel on purpose. Everything
else here is sub-pixel and that is what makes it look good, but splitting a
3 px glyph across two columns halves its peak and smears it illegible. Crisp
beats smooth when the thing has to be read.

site.environment and site.enclosure record where the sensor lives and what has
changed around it, with POST /api/environment to change them at runtime. This
is not cosmetic: closing a door changes how strongly the sensor couples to
outside, which is a regime change in the process the heads are fitting, and at
lambda 0.9985 they carry about 55 hours of memory. Left alone they keep
predicting the old room for two days. Page-Hinkley would notice eventually but
needs matured forecasts to do it, which at the long horizons is the same two
days. So the endpoint marks a discontinuity and queues a retrain.
This commit is contained in:
2026-08-15 23:38:27 +01:00
parent 23cd76c96e
commit 50b29f8077
4 changed files with 212 additions and 4 deletions
+26
View File
@@ -128,6 +128,12 @@ class CalibrationIn(BaseModel):
"covariance, returning to the configured prior")
class EnvironmentIn(BaseModel):
environment: Optional[str] = Field(None, description="indoor | sheltered | outdoor")
enclosure: Optional[str] = Field(None, description="closed | ventilated | open")
note: str = Field("", description="what changed, for the log")
class HumidityCalibrationIn(BaseModel):
reference_pct: Optional[float] = Field(None, ge=0, le=100,
description="Trusted relative humidity in %")
@@ -600,6 +606,24 @@ def recompute() -> Dict:
return _clean(result)
@app.post("/api/environment")
def environment(body: EnvironmentIn) -> Dict:
"""Tell the station its surroundings changed, and have it react.
Marks a discontinuity and queues a retrain, because the learners' 55 hour
memory would otherwise keep predicting the old regime for two days.
"""
valid_env = {"indoor", "sheltered", "outdoor"}
valid_enc = {"closed", "ventilated", "open"}
if body.environment and body.environment not in valid_env:
raise HTTPException(422, f"environment must be one of {sorted(valid_env)}")
if body.enclosure and body.enclosure not in valid_enc:
raise HTTPException(422, f"enclosure must be one of {sorted(valid_enc)}")
if not body.environment and not body.enclosure:
raise HTTPException(422, "provide environment, enclosure, or both")
return _clean(_st().set_environment(body.environment, body.enclosure, body.note))
@app.get("/api/status")
def status() -> Dict:
st = _st()
@@ -607,6 +631,8 @@ def status() -> Dict:
**st.status(),
"display_frame": display.frame_name if display else None,
"outdoor_probe": (st.probe.status() if st.probe is not None else None),
"environment": CONFIG.site.environment,
"enclosure": CONFIG.site.enclosure,
"events": st.store.recent_events(15),
})