State
State is the current value of all properties across all entities, versioned by revision.
Purpose
Hold in-memory state and emit deltas to frontends efficiently.
Backend → Runtime
python
pump.update(pressure=6.3, temperature=42.3)Runtime → Frontend (WebSocket delta)
json
{
"entity": "pump-01",
"revision": 106,
"changes": { "pressure": 6.3 }
}Fetch full state
GET /statejson
{
"pump-01": {
"revision": 106,
"values": { "pressure": 6.3, "temperature": 42.3, "power": true }
}
}Bandwidth controls
Number(max_rate=2)— at most 2 updates/sec to frontendNumber(deadband=0.1)— skip changes smaller than 0.1
Both reduce runtime→frontend emission only. Upstream ingestion is never throttled.
Constraints
- State is in-memory for MVP (no database)
- Revision increments only when a change is actually emitted
Common mistakes
- Assuming
update()always emits — deadband/rate can suppress it (returnsNone) - Writing values directly to
_stateinstead of usingupdate()