Fix TRV status ingestion: subscribe to live shellies/+/status topic
The firmware actually running on the deployed TRVs (SHTRV-01 v2.2.4, confirmed against live hardware) publishes a combined status blob on shellies/<id>/status, not the per-field shellies/<id>/thermostat/0/target_t topic handleStatus() was written against — so current_target_temp was permanently NULL and the dashboard modal always showed "—". Adds handleStatusBlob() to parse the real payload shape and populate current_target_temp/current_room_temp/battery_pct. This firmware also has no guest-vs-automation 'source' field, so guest detection is redesigned to diff an incoming target_t against a new last_commanded_target_t column, stamped by publishTarget() right before every command is sent. A mismatch means the guest changed it via the dial; a match means it's an echo of our own automation. Old handleStatus()/topicMatchesStatus() path left in place, dormant — harmless if some future firmware does use per-field topics. TRV command topic (shellies/<id>/thermostat/0/command/target_t) is still unverified against live hardware — flagged in code comments.
This commit is contained in:
parent
1a06a860f5
commit
807a27ca1b
2 changed files with 74 additions and 4 deletions
|
|
@ -176,6 +176,13 @@ export async function initDb() {
|
|||
await pool.query(`ALTER TABLE zone_devices ADD COLUMN IF NOT EXISTS remote_locked BOOLEAN`)
|
||||
await pool.query(`ALTER TABLE zone_devices ADD COLUMN IF NOT EXISTS status_updated_at TIMESTAMPTZ`)
|
||||
|
||||
// Live TRV firmware (SHTRV-01 v2.2.4, confirmed 2026-08-25) publishes a combined
|
||||
// status blob with no guest-vs-automation 'source' field the old archived logic
|
||||
// relied on. Guest detection is done by diffing an incoming target_t against the
|
||||
// last value hvac itself commanded — stamped here right before every publish, read
|
||||
// back in mqtt.js's status handler. A mismatch = guest changed it via the dial.
|
||||
await pool.query(`ALTER TABLE zone_devices ADD COLUMN IF NOT EXISTS last_commanded_target_t NUMERIC(4,1)`)
|
||||
|
||||
// Default-template rollout: existing installs created occupied_temp/vacant_temp/
|
||||
// heating_offset_min/cooling_offset_min as NOT NULL with a hardcoded default — relax
|
||||
// that so NULL can mean "inherit the global hvac_defaults template" (see seedDefaults()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue