From e60ac0c059ba203e8cbd353126893b62aa4e2911 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 1 Jul 2026 20:57:39 +0000 Subject: [PATCH] Fix real-time house-mode updates: hub-mode notify uses component "hub" A house-mode-change evt.pd7.notify is broadcast on the hub component (component "hub", id "mode"), not component "mode". The previous guard `notify.component !== 'mode'` discarded every real mode-change notification, so the Mode select only updated via the 30s poll fallback instead of in real time. Gate on component "hub" (and, defensively, "mode") and extract the new mode from either param.mode.current (primefimp Hub/HubMode) or param.current (edge-iqcontrols/tpflow references), publishing only when a mode string is found. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01FuQAyPde4K57P2XMCKbFek --- futurehome/src/ha/hub_mode.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/futurehome/src/ha/hub_mode.ts b/futurehome/src/ha/hub_mode.ts index 220383d..92a2955 100644 --- a/futurehome/src/ha/hub_mode.ts +++ b/futurehome/src/ha/hub_mode.ts @@ -137,22 +137,36 @@ export function publishHubModeFromHouseResponse(parameters: { /** * Handles a Vinculum `evt.pd7.notify` message and, when it reports a house mode - * change (`component: "mode"`, `param: { current, prev }`), updates the Home - * Assistant "Mode" entity. This is what reflects a Futurehome Modeswitch button - * press (or an app / automation mode change) in Home Assistant in real time. + * change, updates the Home Assistant "Mode" entity. This is what reflects a + * Futurehome Modeswitch button press (or an app / automation mode change) in + * Home Assistant in real time. + * + * A mode change is broadcast on the hub component (`component: "hub"`, + * `id: "mode"`). The new value has been observed both nested as + * `param.mode.current` (see `primefimp` `Hub`/`HubMode`) and flat as + * `param.current` (see the `edge-iqcontrols` / `tpflow` references), so both + * are handled; the defensive `component: "mode"` case is handled too. */ export function handleModeNotify(parameters: { hubId: string; msg: FimpResponse; }): void { const notify = parameters.msg.val; - if (!notify || notify.component !== 'mode') { + if (!notify) { + return; + } + if (notify.component !== 'hub' && notify.component !== 'mode') { return; } + const param = notify.param ?? {}; const current = - (typeof notify.param?.current === 'string' && notify.param.current) || - (typeof notify.id === 'string' && notify.id) || + (typeof param.mode === 'object' && + param.mode && + typeof param.mode.current === 'string' && + param.mode.current) || + (typeof param.current === 'string' && param.current) || + (typeof param.mode === 'string' && param.mode) || undefined; if (current) {