From b892e209205e8e2fd90baa277a033d1be215eeb0 Mon Sep 17 00:00:00 2001 From: Adrian Jagielak Date: Wed, 1 Jul 2026 23:38:08 +0200 Subject: [PATCH] Expose battery maintenance status (e.g. replace_now) as a sensor Some battery devices report a full battery level while still signalling that the battery must be replaced (the customer's log shows devices at lvl 100 with state "replace_now"). That maintenance state was not surfaced anywhere. When the battery service supports the replace_* events (per its `sup_events` property), expose the hub-reported `state` attribute as a diagnostic "Battery status" sensor. --- futurehome/CHANGELOG.md | 4 ++++ futurehome/config.yaml | 2 +- futurehome/src/services/battery.ts | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/futurehome/CHANGELOG.md b/futurehome/CHANGELOG.md index 27cd32b..940d29f 100644 --- a/futurehome/CHANGELOG.md +++ b/futurehome/CHANGELOG.md @@ -1,5 +1,9 @@ +## 1.8.0 (01.07.2026) + +- Expose the battery maintenance status (e.g. `replace_now`) as a diagnostic "Battery status" sensor for devices that support the `replace_*` battery events. Previously this was not surfaced at all, so a device could report a full battery level while actually needing its battery replaced. + ## 1.7.0 (01.07.2026) - Added support for the Futurehome house mode (Home/Away/Sleep/Vacation). The current mode is exposed as a `Mode` selector on the Smarthub device, updates in real time (e.g. when a Futurehome Modeswitch button is pressed), and can be changed from Home Assistant. diff --git a/futurehome/config.yaml b/futurehome/config.yaml index f17913a..f5603dc 100644 --- a/futurehome/config.yaml +++ b/futurehome/config.yaml @@ -1,6 +1,6 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: Futurehome -version: '1.7.0' +version: '1.8.0' slug: futurehome description: Local Futurehome Smarthub integration url: 'https://github.com/adrianjagielak/home-assistant-futurehome' diff --git a/futurehome/src/services/battery.ts b/futurehome/src/services/battery.ts index c94a990..67dd1f6 100644 --- a/futurehome/src/services/battery.ts +++ b/futurehome/src/services/battery.ts @@ -32,6 +32,26 @@ export function battery__components( }; } + // Battery maintenance status (e.g. "replace_now"). A device can report a full + // battery level while still asking to be replaced, so when it supports the + // replace_* events this is surfaced as its own diagnostic sensor. The hub + // reports the current state as a plain string in the `state` attribute. + const supEvents: string[] = svc.props?.sup_events ?? []; + if ( + supEvents.some( + (event) => typeof event === 'string' && event.startsWith('replace'), + ) + ) { + components[`${svc.addr}_state`] = { + unique_id: `${svc.addr}_state`, + platform: 'sensor', + entity_category: 'diagnostic', + icon: 'mdi:battery-heart-variant', + name: 'Battery status', + value_template: `{{ value_json['${svc.addr}'].state | default('ok', true) }}`, + }; + } + return { components: components, };