mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2026-07-07 13:23:03 +00:00
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FuQAyPde4K57P2XMCKbFek
This commit is contained in:
@@ -137,22 +137,36 @@ export function publishHubModeFromHouseResponse(parameters: {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a Vinculum `evt.pd7.notify` message and, when it reports a house mode
|
* Handles a Vinculum `evt.pd7.notify` message and, when it reports a house mode
|
||||||
* change (`component: "mode"`, `param: { current, prev }`), updates the Home
|
* change, updates the Home Assistant "Mode" entity. This is what reflects a
|
||||||
* Assistant "Mode" entity. This is what reflects a Futurehome Modeswitch button
|
* Futurehome Modeswitch button press (or an app / automation mode change) in
|
||||||
* press (or an app / automation mode change) in Home Assistant in real time.
|
* 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: {
|
export function handleModeNotify(parameters: {
|
||||||
hubId: string;
|
hubId: string;
|
||||||
msg: FimpResponse;
|
msg: FimpResponse;
|
||||||
}): void {
|
}): void {
|
||||||
const notify = parameters.msg.val;
|
const notify = parameters.msg.val;
|
||||||
if (!notify || notify.component !== 'mode') {
|
if (!notify) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (notify.component !== 'hub' && notify.component !== 'mode') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const param = notify.param ?? {};
|
||||||
const current =
|
const current =
|
||||||
(typeof notify.param?.current === 'string' && notify.param.current) ||
|
(typeof param.mode === 'object' &&
|
||||||
(typeof notify.id === 'string' && notify.id) ||
|
param.mode &&
|
||||||
|
typeof param.mode.current === 'string' &&
|
||||||
|
param.mode.current) ||
|
||||||
|
(typeof param.current === 'string' && param.current) ||
|
||||||
|
(typeof param.mode === 'string' && param.mode) ||
|
||||||
undefined;
|
undefined;
|
||||||
|
|
||||||
if (current) {
|
if (current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user