From 9aac6c489fdd668034205b40b5bcad6a2f96e31a Mon Sep 17 00:00:00 2001 From: Adrian Jagielak Date: Sun, 27 Jul 2025 00:31:18 +0200 Subject: [PATCH] Add support for 'dev_sys' service --- README.md | 43 +++++++++++------------- futurehome/CHANGELOG.md | 1 + futurehome/README.md | 43 +++++++++++------------- futurehome/src/ha/publish_device.ts | 2 ++ futurehome/src/services/dev_sys.ts | 51 +++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 48 deletions(-) create mode 100644 futurehome/src/services/dev_sys.ts diff --git a/README.md b/README.md index a6eca65..0355583 100644 --- a/README.md +++ b/README.md @@ -61,35 +61,30 @@ todo add info about factory reset hub to restore 30 day trial | Keypad | [user_code](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/user_code.ts) | | ✅ | [Sensor](https://www.home-assistant.io/integrations/sensor/), [Binary sensor](https://www.home-assistant.io/integrations/binary_sensor/), [Button](https://www.home-assistant.io/integrations/button/), [Text](https://www.home-assistant.io/integrations/text/)| | Water heater | [water_heater](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/water_heater.ts) | | ✅ | [Water heater](https://www.home-assistant.io/integrations/water_heater/) | -## Problematic services +## Implemented system services + +| Name | Service | Implementation status | Home Assistant entity | +| --- | --- | --- | --- | +| Identify device | [indicator_ctrl](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/indicator_ctrl.ts) | | ✅ | [Button](https://www.home-assistant.io/integrations/button/) | +| Reboot device | [dev_sys](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/dev_sys.ts) | | ✅ | [Button](https://www.home-assistant.io/integrations/button/) | + +## Other system, meta, unused, or not essential services | Service | Description | | --- | --- | -| schedule | No devices or hub support this stub service. | +| association | | | battery_charge_ctrl | No devices or hub support this stub service. | +| diagnostic | Diagnostic (logging, etc) | +| gateway | | | inverter_consumer_conn | No devices or hub support this stub service. | | inverter_grid_conn | No devices or hub support this stub service. | | inverter_solar_conn | No devices or hub support this stub service. | - -## Virtual, unnecessary services (easily reproduced in stock Home Assistant) - -| Service | Description | -| --- | --- | -| virtual_meter_elec | A virtual electricity meter that estimates energy usage by multiplying the device's configured average power consumption with its operating duration. | - -## System or meta, not essential services - -| Service | Implementation status | Description | -| --- | --- | --- | -| gateway | | | -| association | | | -| diagnostic | | | -| indicator_ctrl | ✅ | Identify devices | -| ota | | | -| parameters | | | +| ota | Managing OTA updates of devices | +| parameters | | | Power regulator | [power_regulator](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/power_regulator.ts) | [16A Puck Relé](https://www.futurehome.io/en_no/shop/puck-relay-16a) | | | -| technology_specific | | | -| time | | | -| time_parameters | | -| version | | | -| dev_sys | | | +| schedule | No devices or hub support this stub service. | +| technology_specific | | +| time | Z-wave service for setting and reading time | +| time_parameters | Z-wave service for setting and reading time | +| version | Device hardware and software versions. Exposed through other means. | +| virtual_meter_elec | A virtual electricity meter that estimates energy usage by multiplying the device's configured average power consumption with its operating duration. Easily reproducible using Home Assistant's built-in configuration. | diff --git a/futurehome/CHANGELOG.md b/futurehome/CHANGELOG.md index c6f7b26..170f707 100644 --- a/futurehome/CHANGELOG.md +++ b/futurehome/CHANGELOG.md @@ -11,6 +11,7 @@ - Added support for 'schedule_entry' service (for scheduling access). - Added support for 'doorman' service (Yale door locks). - Added support for 'complex_alarm_system' service (part of alarm sirens control). +- Added support for 'dev_sys' service (reboot device). ## 0.1.5 (25.07.2025) diff --git a/futurehome/README.md b/futurehome/README.md index f964161..e705de3 100644 --- a/futurehome/README.md +++ b/futurehome/README.md @@ -60,35 +60,30 @@ todo add info about factory reset hub to restore 30 day trial | Keypad | [user_code](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/user_code.ts) | | ✅ | [Sensor](https://www.home-assistant.io/integrations/sensor/), [Binary sensor](https://www.home-assistant.io/integrations/binary_sensor/), [Button](https://www.home-assistant.io/integrations/button/), [Text](https://www.home-assistant.io/integrations/text/)| | Water heater | [water_heater](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/water_heater.ts) | | ✅ | [Water heater](https://www.home-assistant.io/integrations/water_heater/) | -## Problematic services +## Implemented system services + +| Name | Service | Implementation status | Home Assistant entity | +| --- | --- | --- | --- | +| Identify device | [indicator_ctrl](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/indicator_ctrl.ts) | | ✅ | [Button](https://www.home-assistant.io/integrations/button/) | +| Reboot device | [dev_sys](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/dev_sys.ts) | | ✅ | [Button](https://www.home-assistant.io/integrations/button/) | + +## Other system, meta, unused, or not essential services | Service | Description | | --- | --- | -| schedule | No devices or hub support this stub service. | +| association | | | battery_charge_ctrl | No devices or hub support this stub service. | +| diagnostic | Diagnostic (logging, etc) | +| gateway | | | inverter_consumer_conn | No devices or hub support this stub service. | | inverter_grid_conn | No devices or hub support this stub service. | | inverter_solar_conn | No devices or hub support this stub service. | - -## Virtual, unnecessary services (easily reproduced in stock Home Assistant) - -| Service | Description | -| --- | --- | -| virtual_meter_elec | A virtual electricity meter that estimates energy usage by multiplying the device's configured average power consumption with its operating duration. | - -## System or meta, not essential services - -| Service | Implementation status | Description | -| --- | --- | --- | -| gateway | | | -| association | | | -| diagnostic | | | -| indicator_ctrl | ✅ | Identify devices | -| ota | | | -| parameters | | | +| ota | Managing OTA updates of devices | +| parameters | | | Power regulator | [power_regulator](https://github.com/adrianjagielak/home-assistant-futurehome/blob/master/futurehome/src/services/power_regulator.ts) | [16A Puck Relé](https://www.futurehome.io/en_no/shop/puck-relay-16a) | | | -| technology_specific | | | -| time | | | -| time_parameters | | -| version | | | -| dev_sys | | | +| schedule | No devices or hub support this stub service. | +| technology_specific | | +| time | Z-wave service for setting and reading time | +| time_parameters | Z-wave service for setting and reading time | +| version | Device hardware and software versions. Exposed through other means. | +| virtual_meter_elec | A virtual electricity meter that estimates energy usage by multiplying the device's configured average power consumption with its operating duration. Easily reproducible using Home Assistant's built-in configuration. | diff --git a/futurehome/src/ha/publish_device.ts b/futurehome/src/ha/publish_device.ts index b8d3583..894bb64 100644 --- a/futurehome/src/ha/publish_device.ts +++ b/futurehome/src/ha/publish_device.ts @@ -14,6 +14,7 @@ import { battery__components } from '../services/battery'; import { chargepoint__components } from '../services/chargepoint'; import { color_ctrl__components } from '../services/color_ctrl'; import { complex_alarm_system__components } from '../services/complex_alarm_system'; +import { dev_sys__components } from '../services/dev_sys'; import { door_lock__components } from '../services/door_lock'; import { doorman__components } from '../services/doorman'; import { fan_ctrl__components } from '../services/fan_ctrl'; @@ -155,6 +156,7 @@ const serviceHandlers: { chargepoint: chargepoint__components, color_ctrl: color_ctrl__components, complex_alarm_system: complex_alarm_system__components, + dev_sys: dev_sys__components, door_lock: door_lock__components, doorman: doorman__components, fan_ctrl: fan_ctrl__components, diff --git a/futurehome/src/services/dev_sys.ts b/futurehome/src/services/dev_sys.ts new file mode 100644 index 0000000..58db87b --- /dev/null +++ b/futurehome/src/services/dev_sys.ts @@ -0,0 +1,51 @@ +import { sendFimpMsg } from '../fimp/fimp'; +import { + VinculumPd7Device, + VinculumPd7Service, +} from '../fimp/vinculum_pd7_device'; +import { HaMqttComponent } from '../ha/mqtt_components/_component'; +import { + CommandHandlers, + ServiceComponentsCreationResult, +} from '../ha/publish_device'; + +export function dev_sys__components( + topicPrefix: string, + device: VinculumPd7Device, + svc: VinculumPd7Service, + svcName: string, +): ServiceComponentsCreationResult | undefined { + const components: Record = {}; + const commandHandlers: CommandHandlers = {}; + + if (svc.intf?.includes('cmd.thing.reboot')) { + const rebootCommandTopic = `${topicPrefix}${svc.addr}/reboot/command`; + + components[`${svc.addr}_reboot`] = { + unique_id: `${svc.addr}_reboot`, + platform: 'button', + device_class: 'restart', + entity_category: 'config', + command_topic: rebootCommandTopic, + }; + + commandHandlers[rebootCommandTopic] = async (_payload: string) => { + await sendFimpMsg({ + address: svc.addr, + service: svcName, + cmd: 'cmd.thing.reboot', + // App always sends a `null`. In theory some devices could support a force reboot, with `true` value. + val_t: 'null', + val: null, + }); + }; + } + + // Nothing useful to expose? + if (!Object.keys(components).length) return undefined; + + return { + components, + commandHandlers, + }; +}