From 8dfd40a5d7a8b3dc49cf4a57f8a5dae0f404a0c5 Mon Sep 17 00:00:00 2001 From: Adrian Jagielak Date: Thu, 24 Jul 2025 20:57:05 +0200 Subject: [PATCH] Set battery entity categories to 'diagnostic' to hide them from the main view --- futurehome/CHANGELOG.md | 5 + futurehome/config.yaml | 2 +- futurehome/src/ha/mqtt_components/_enums.ts | 1 + .../ha/mqtt_components/alarm_control_panel.ts | 20 ++-- .../src/ha/mqtt_components/binary_sensor.ts | 22 ++--- futurehome/src/ha/mqtt_components/button.ts | 20 ++-- futurehome/src/ha/mqtt_components/camera.ts | 20 ++-- futurehome/src/ha/mqtt_components/climate.ts | 93 ++---------------- futurehome/src/ha/mqtt_components/cover.ts | 20 ++-- .../ha/mqtt_components/device_automation.ts | 10 ++ .../src/ha/mqtt_components/device_tracker.ts | 10 ++ futurehome/src/ha/mqtt_components/event.ts | 20 ++-- futurehome/src/ha/mqtt_components/fan.ts | 22 ++--- .../src/ha/mqtt_components/humidifier.ts | 22 ++--- futurehome/src/ha/mqtt_components/image.ts | 95 +++---------------- .../src/ha/mqtt_components/lawn_mower.ts | 22 ++--- futurehome/src/ha/mqtt_components/light.ts | 22 ++--- futurehome/src/ha/mqtt_components/lock.ts | 22 ++--- .../src/ha/mqtt_components/manual_mqtt.ts | 12 ++- futurehome/src/ha/mqtt_components/notify.ts | 22 ++--- futurehome/src/ha/mqtt_components/number.ts | 22 ++--- futurehome/src/ha/mqtt_components/scene.ts | 22 ++--- futurehome/src/ha/mqtt_components/select.ts | 22 ++--- futurehome/src/ha/mqtt_components/sensor.ts | 24 ++--- futurehome/src/ha/mqtt_components/siren.ts | 22 ++--- futurehome/src/ha/mqtt_components/switch.ts | 22 ++--- futurehome/src/ha/mqtt_components/tag.ts | 12 ++- futurehome/src/ha/mqtt_components/text.ts | 22 ++--- futurehome/src/ha/mqtt_components/update.ts | 22 ++--- futurehome/src/ha/mqtt_components/vacuum.ts | 12 ++- futurehome/src/ha/mqtt_components/valve.ts | 22 ++--- .../src/ha/mqtt_components/water_heater.ts | 22 ++--- futurehome/src/services/battery.ts | 18 ++-- 33 files changed, 328 insertions(+), 418 deletions(-) create mode 100644 futurehome/src/ha/mqtt_components/_enums.ts diff --git a/futurehome/CHANGELOG.md b/futurehome/CHANGELOG.md index 33bdd7c..1250050 100644 --- a/futurehome/CHANGELOG.md +++ b/futurehome/CHANGELOG.md @@ -1,6 +1,11 @@ +## 0.1.1 (24.07.2025) + +- Set 'battery' entity category to 'diagnostic' to hide it from the main HA view. +- Do not expose 'battery' entity twice if it supports both level and low/high binary state. + ## 0.1.0 (24.07.2025) **Initial stable release** diff --git a/futurehome/config.yaml b/futurehome/config.yaml index cd24c80..b5e4206 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: "0.1.0" +version: "0.1.1" slug: futurehome description: Local Futurehome Smarthub integration url: "https://github.com/adrianjagielak/home-assistant-futurehome" diff --git a/futurehome/src/ha/mqtt_components/_enums.ts b/futurehome/src/ha/mqtt_components/_enums.ts new file mode 100644 index 0000000..47fe407 --- /dev/null +++ b/futurehome/src/ha/mqtt_components/_enums.ts @@ -0,0 +1 @@ +export type EntityCategory = undefined | 'config' | 'diagnostic'; diff --git a/futurehome/src/ha/mqtt_components/alarm_control_panel.ts b/futurehome/src/ha/mqtt_components/alarm_control_panel.ts index fd49f5a..cc715ad 100644 --- a/futurehome/src/ha/mqtt_components/alarm_control_panel.ts +++ b/futurehome/src/ha/mqtt_components/alarm_control_panel.ts @@ -26,6 +26,16 @@ export interface AlarmControlPanelComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * The MQTT topic subscribed to receive state updates. * A `None` payload resets to an `unknown` state. @@ -89,16 +99,6 @@ export interface AlarmControlPanelComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/binary_sensor.ts b/futurehome/src/ha/mqtt_components/binary_sensor.ts index 5a30a9b..7062d34 100644 --- a/futurehome/src/ha/mqtt_components/binary_sensor.ts +++ b/futurehome/src/ha/mqtt_components/binary_sensor.ts @@ -13,6 +13,17 @@ export interface BinarySensorComponent { */ platform: 'binary_sensor'; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + * When set, the entity category must be `diagnostic` for sensors. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * An ID that uniquely identifies this sensor. * If two sensors have the same unique ID, Home Assistant will raise an exception. @@ -103,17 +114,6 @@ export interface BinarySensorComponent { */ qos?: number; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity/#generic-properties) of the entity. - * When set, the entity category must be `diagnostic` for sensors. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/button.ts b/futurehome/src/ha/mqtt_components/button.ts index a1a0cac..08bc1ea 100644 --- a/futurehome/src/ha/mqtt_components/button.ts +++ b/futurehome/src/ha/mqtt_components/button.ts @@ -21,6 +21,16 @@ export interface ButtonComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * The MQTT topic to publish commands to trigger the button. */ @@ -56,16 +66,6 @@ export interface ButtonComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/camera.ts b/futurehome/src/ha/mqtt_components/camera.ts index 69e99ac..4509fac 100644 --- a/futurehome/src/ha/mqtt_components/camera.ts +++ b/futurehome/src/ha/mqtt_components/camera.ts @@ -22,6 +22,16 @@ export interface CameraComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * The MQTT topic to subscribe to. */ @@ -41,16 +51,6 @@ export interface CameraComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/climate.ts b/futurehome/src/ha/mqtt_components/climate.ts index 8a1da4b..6cea0c4 100644 --- a/futurehome/src/ha/mqtt_components/climate.ts +++ b/futurehome/src/ha/mqtt_components/climate.ts @@ -20,6 +20,16 @@ export interface ClimateComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * A template to render the value received on the `action_topic` with. */ @@ -57,79 +67,6 @@ export interface ClimateComponent { */ current_temperature_topic?: string; - /** - * Information about the device this HVAC device is a part of to tie it into the [device registry](https://developers.home-assistant.io/docs/en/device_registry_index.html). - * Only works when [`unique_id`](#unique_id) is set. - * At least one of identifiers or connections must be present to identify the device. - */ - device?: { - /** - * A link to the webpage that can manage the configuration of this device. - * Can be either an `http://`, `https://` or an internal `homeassistant://` URL. - */ - configuration_url?: string; - - /** - * A list of connections of the device to the outside world as a list of tuples `[connection_type, connection_identifier]`. - * For example the MAC address of a network interface: - * `"connections": [["mac", "02:5b:26:a8:dc:12"]]`. - */ - connections?: Array<[string, string]>; - - /** - * The hardware version of the device. - */ - hw_version?: string; - - /** - * A list of IDs that uniquely identify the device. - * For example a serial number. - */ - identifiers?: string[]; - - /** - * The manufacturer of the device. - */ - manufacturer?: string; - - /** - * The model of the device. - */ - model?: string; - - /** - * The model identifier of the device. - */ - model_id?: string; - - /** - * The name of the device. - */ - name?: string; - - /** - * The serial number of the device. - */ - serial_number?: string; - - /** - * Suggest an area if the device isn’t in one yet. - */ - suggested_area?: string; - - /** - * The firmware version of the device. - */ - sw_version?: string; - - /** - * Identifier of a device that routes messages between this device and Home Assistant. - * Examples of such devices are hubs, or parent devices of a sub-device. - * This is used to show device topology in Home Assistant. - */ - via_device?: string; - }; - /** * Flag which defines if the entity should be enabled when first added. * Default: true. @@ -143,16 +80,6 @@ export interface ClimateComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * A template to render the value sent to the `fan_mode_command_topic` with. */ diff --git a/futurehome/src/ha/mqtt_components/cover.ts b/futurehome/src/ha/mqtt_components/cover.ts index 98078af..7fab989 100644 --- a/futurehome/src/ha/mqtt_components/cover.ts +++ b/futurehome/src/ha/mqtt_components/cover.ts @@ -20,6 +20,16 @@ export interface CoverComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * The MQTT topic to publish commands to control the cover. */ @@ -45,16 +55,6 @@ export interface CoverComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/device_automation.ts b/futurehome/src/ha/mqtt_components/device_automation.ts index 65fa9e5..923fc59 100644 --- a/futurehome/src/ha/mqtt_components/device_automation.ts +++ b/futurehome/src/ha/mqtt_components/device_automation.ts @@ -25,6 +25,16 @@ export interface DeviceAutomationComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * The type of automation, must be 'trigger'. */ diff --git a/futurehome/src/ha/mqtt_components/device_tracker.ts b/futurehome/src/ha/mqtt_components/device_tracker.ts index da1a303..12ac3dc 100644 --- a/futurehome/src/ha/mqtt_components/device_tracker.ts +++ b/futurehome/src/ha/mqtt_components/device_tracker.ts @@ -21,6 +21,16 @@ export interface DeviceTrackerComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * The MQTT topic subscribed to receive device tracker state changes. * The states defined in `state_topic` override the location states defined by the `json_attributes_topic`. diff --git a/futurehome/src/ha/mqtt_components/event.ts b/futurehome/src/ha/mqtt_components/event.ts index 98d7f8a..73135eb 100644 --- a/futurehome/src/ha/mqtt_components/event.ts +++ b/futurehome/src/ha/mqtt_components/event.ts @@ -23,6 +23,16 @@ export interface EventComponent { */ unique_id: string; + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; + /** * The MQTT topic subscribed to receive JSON event payloads. * The JSON payload should contain the `event_type` element. @@ -54,16 +64,6 @@ export interface EventComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity/#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * Defines a [template](https://www.home-assistant.io/docs/configuration/templating/#using-value-templates-with-mqtt) * to extract the JSON dictionary from messages received on the `json_attributes_topic`. diff --git a/futurehome/src/ha/mqtt_components/fan.ts b/futurehome/src/ha/mqtt_components/fan.ts index 75434eb..6ba1e2c 100644 --- a/futurehome/src/ha/mqtt_components/fan.ts +++ b/futurehome/src/ha/mqtt_components/fan.ts @@ -18,7 +18,17 @@ export interface FanComponent { * If two fans have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish commands to change the fan state. @@ -183,16 +193,6 @@ export interface FanComponent { */ retain?: boolean; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/humidifier.ts b/futurehome/src/ha/mqtt_components/humidifier.ts index c73e8bf..c94957e 100644 --- a/futurehome/src/ha/mqtt_components/humidifier.ts +++ b/futurehome/src/ha/mqtt_components/humidifier.ts @@ -18,7 +18,17 @@ export interface HumidifierComponent { * If two humidifiers have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish commands to change the humidifier state. @@ -203,16 +213,6 @@ export interface HumidifierComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/image.ts b/futurehome/src/ha/mqtt_components/image.ts index d89c4ef..5e77ea4 100644 --- a/futurehome/src/ha/mqtt_components/image.ts +++ b/futurehome/src/ha/mqtt_components/image.ts @@ -23,7 +23,17 @@ export interface ImageComponent { * If two images have the same unique ID Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to subscribe to receive the image payload of the image to be downloaded. @@ -99,91 +109,8 @@ export interface ImageComponent { */ json_attributes_template?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ icon?: string; - - /** - * Information about the device this image is a part of to tie it into the [device registry](https://developers.home-assistant.io/docs/en/device_registry_index.html). - * Only works through [MQTT discovery](https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery) and when [`unique_id`](#unique_id) is set. - * At least one of identifiers or connections must be present to identify the device. - */ - device?: { - /** - * A link to the webpage that can manage the configuration of this device. - * Can be either an `http://`, `https://` or an internal `homeassistant://` URL. - */ - configuration_url?: string; - - /** - * A list of connections of the device to the outside world as a list of tuples `[connection_type, connection_identifier]`. - * For example the MAC address of a network interface: - * `"connections": [["mac", "02:5b:26:a8:dc:12"]]`. - */ - connections?: Array<[string, string]>; - - /** - * The hardware version of the device. - */ - hw_version?: string; - - /** - * A list of IDs that uniquely identify the device. - * For example a serial number. - */ - identifiers?: string[]; - - /** - * The manufacturer of the device. - */ - manufacturer?: string; - - /** - * The model of the device. - */ - model?: string; - - /** - * The model identifier of the device. - */ - model_id?: string; - - /** - * The name of the device. - */ - name?: string; - - /** - * The serial number of the device. - */ - serial_number?: string; - - /** - * Suggest an area if the device isn’t in one yet. - */ - suggested_area?: string; - - /** - * The firmware version of the device. - */ - sw_version?: string; - - /** - * Identifier of a device that routes messages between this device and Home Assistant. - * Examples of such devices are hubs, or parent devices of a sub-device. - * This is used to show device topology in Home Assistant. - */ - via_device?: string; - }; } diff --git a/futurehome/src/ha/mqtt_components/lawn_mower.ts b/futurehome/src/ha/mqtt_components/lawn_mower.ts index 192729a..f96acf2 100644 --- a/futurehome/src/ha/mqtt_components/lawn_mower.ts +++ b/futurehome/src/ha/mqtt_components/lawn_mower.ts @@ -18,7 +18,17 @@ export interface LawnMowerComponent { * If two lawn mowers have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic subscribed to receive an update of the activity. @@ -60,16 +70,6 @@ export interface LawnMowerComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/light.ts b/futurehome/src/ha/mqtt_components/light.ts index f1e59e8..ef853ce 100644 --- a/futurehome/src/ha/mqtt_components/light.ts +++ b/futurehome/src/ha/mqtt_components/light.ts @@ -19,7 +19,17 @@ export interface LightComponent { * If two lights have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * Flag that defines if light supports brightness when the `rgb`, `rgbw`, or `rgbww` color mode is supported. @@ -336,16 +346,6 @@ export interface LightComponent { */ object_id?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/lock.ts b/futurehome/src/ha/mqtt_components/lock.ts index 56e47b4..7b2de8b 100644 --- a/futurehome/src/ha/mqtt_components/lock.ts +++ b/futurehome/src/ha/mqtt_components/lock.ts @@ -18,7 +18,17 @@ export interface LockComponent { * If two locks have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish commands to change the lock state. @@ -60,16 +70,6 @@ export interface LockComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/manual_mqtt.ts b/futurehome/src/ha/mqtt_components/manual_mqtt.ts index 831a2f3..af13366 100644 --- a/futurehome/src/ha/mqtt_components/manual_mqtt.ts +++ b/futurehome/src/ha/mqtt_components/manual_mqtt.ts @@ -23,7 +23,17 @@ export interface ManualMqttComponent { * If two manual alarm control panels have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic Home Assistant will publish state updates to. diff --git a/futurehome/src/ha/mqtt_components/notify.ts b/futurehome/src/ha/mqtt_components/notify.ts index 474fd24..99ef978 100644 --- a/futurehome/src/ha/mqtt_components/notify.ts +++ b/futurehome/src/ha/mqtt_components/notify.ts @@ -20,7 +20,17 @@ export interface NotifyComponent { * If two notify entities have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish send message commands at. @@ -39,16 +49,6 @@ export interface NotifyComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/number.ts b/futurehome/src/ha/mqtt_components/number.ts index 08d3792..ab1a089 100644 --- a/futurehome/src/ha/mqtt_components/number.ts +++ b/futurehome/src/ha/mqtt_components/number.ts @@ -21,7 +21,17 @@ export interface NumberComponent { * If two number entities have the same unique ID Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish commands to change the number. @@ -92,16 +102,6 @@ export interface NumberComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/scene.ts b/futurehome/src/ha/mqtt_components/scene.ts index 79c763d..83c3227 100644 --- a/futurehome/src/ha/mqtt_components/scene.ts +++ b/futurehome/src/ha/mqtt_components/scene.ts @@ -17,7 +17,17 @@ export interface SceneComponent { * If two scenes have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish `payload_on` to activate the scene. @@ -48,16 +58,6 @@ export interface SceneComponent { */ enabled_by_default?: boolean; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * The encoding of the published messages. * Default: "utf-8" diff --git a/futurehome/src/ha/mqtt_components/select.ts b/futurehome/src/ha/mqtt_components/select.ts index 9cd7cb8..cd57642 100644 --- a/futurehome/src/ha/mqtt_components/select.ts +++ b/futurehome/src/ha/mqtt_components/select.ts @@ -21,7 +21,17 @@ export interface SelectComponent { * If two selects have the same unique ID Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic subscribed to receive update of the selected option. @@ -82,16 +92,6 @@ export interface SelectComponent { */ enabled_by_default?: boolean; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/sensor.ts b/futurehome/src/ha/mqtt_components/sensor.ts index b22f352..3d4cb21 100644 --- a/futurehome/src/ha/mqtt_components/sensor.ts +++ b/futurehome/src/ha/mqtt_components/sensor.ts @@ -21,7 +21,18 @@ export interface SensorComponent { * If two sensors have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + * When set, the entity category must be `diagnostic` for sensors. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic subscribed to receive sensor values. @@ -94,17 +105,6 @@ export interface SensorComponent { */ qos?: number; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - * When set, the entity category must be `diagnostic` for sensors. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/siren.ts b/futurehome/src/ha/mqtt_components/siren.ts index 6caf08b..e644498 100644 --- a/futurehome/src/ha/mqtt_components/siren.ts +++ b/futurehome/src/ha/mqtt_components/siren.ts @@ -17,7 +17,17 @@ export interface SirenComponent { * If two sirens have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * List of available tones the siren supports. When configured, this enables the support for setting a `tone` and enables the `tone` state attribute. @@ -51,16 +61,6 @@ export interface SirenComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/switch.ts b/futurehome/src/ha/mqtt_components/switch.ts index f39f911..0b127c3 100644 --- a/futurehome/src/ha/mqtt_components/switch.ts +++ b/futurehome/src/ha/mqtt_components/switch.ts @@ -18,7 +18,17 @@ export interface SwitchComponent { * If two switches have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish commands to change the switch state. @@ -51,16 +61,6 @@ export interface SwitchComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/tag.ts b/futurehome/src/ha/mqtt_components/tag.ts index bc126fd..21eebef 100644 --- a/futurehome/src/ha/mqtt_components/tag.ts +++ b/futurehome/src/ha/mqtt_components/tag.ts @@ -18,7 +18,17 @@ export interface TagComponent { * If two tags have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic subscribed to receive tag scanned events. diff --git a/futurehome/src/ha/mqtt_components/text.ts b/futurehome/src/ha/mqtt_components/text.ts index b22f1af..82753df 100644 --- a/futurehome/src/ha/mqtt_components/text.ts +++ b/futurehome/src/ha/mqtt_components/text.ts @@ -19,7 +19,17 @@ export interface TextComponent { * If two text entities have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish the text value that is set. @@ -94,16 +104,6 @@ export interface TextComponent { */ enabled_by_default?: boolean; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * Defines a [template](https://www.home-assistant.io/docs/configuration/templating/#using-value-templates-with-mqtt) * to extract the JSON dictionary from messages received on the `json_attributes_topic`. diff --git a/futurehome/src/ha/mqtt_components/update.ts b/futurehome/src/ha/mqtt_components/update.ts index 4152ff7..ab000d1 100644 --- a/futurehome/src/ha/mqtt_components/update.ts +++ b/futurehome/src/ha/mqtt_components/update.ts @@ -18,7 +18,17 @@ export interface UpdateComponent { * An ID that uniquely identifies this update entity. * If two update entities have the same unique ID, Home Assistant will raise an exception. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic subscribed to receive state updates. @@ -80,16 +90,6 @@ export interface UpdateComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/vacuum.ts b/futurehome/src/ha/mqtt_components/vacuum.ts index 2009fbe..a005265 100644 --- a/futurehome/src/ha/mqtt_components/vacuum.ts +++ b/futurehome/src/ha/mqtt_components/vacuum.ts @@ -19,7 +19,17 @@ export interface VacuumComponent { * If two vacuums have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish commands to control the vacuum. diff --git a/futurehome/src/ha/mqtt_components/valve.ts b/futurehome/src/ha/mqtt_components/valve.ts index b846713..463b1a8 100644 --- a/futurehome/src/ha/mqtt_components/valve.ts +++ b/futurehome/src/ha/mqtt_components/valve.ts @@ -20,7 +20,17 @@ export interface ValveComponent { * If two valves have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The MQTT topic to publish commands to control the valve. @@ -182,16 +192,6 @@ export interface ValveComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/ha/mqtt_components/water_heater.ts b/futurehome/src/ha/mqtt_components/water_heater.ts index b8f6280..52e1726 100644 --- a/futurehome/src/ha/mqtt_components/water_heater.ts +++ b/futurehome/src/ha/mqtt_components/water_heater.ts @@ -18,7 +18,17 @@ export interface WaterHeaterComponent { * If two water heaters have the same unique ID, Home Assistant will raise an exception. * Required when used with device-based discovery. */ - unique_id?: string; + unique_id: string; + + /** + * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. + */ + entity_category?: string; + + /** + * Picture URL for the entity. + */ + entity_picture?: string; /** * The name of the water heater. @@ -45,16 +55,6 @@ export interface WaterHeaterComponent { */ encoding?: string; - /** - * The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity. - */ - entity_category?: string; - - /** - * Picture URL for the entity. - */ - entity_picture?: string; - /** * [Icon](https://www.home-assistant.io/docs/configuration/customizing-devices/#icon) for the entity. */ diff --git a/futurehome/src/services/battery.ts b/futurehome/src/services/battery.ts index 3f3e219..ec67b86 100644 --- a/futurehome/src/services/battery.ts +++ b/futurehome/src/services/battery.ts @@ -12,23 +12,23 @@ export function battery__components( ): ServiceComponentsCreationResult | undefined { const components: Record = {}; - if (svc.intf?.includes('evt.alarm.report')) { - components[`${svc.addr}_alarm`] = { - unique_id: `${svc.addr}_alarm`, - platform: 'binary_sensor', - device_class: 'battery', - value_template: `{{ (value_json['${svc.addr}'].alarm.status == 'activ') | iif('ON', 'OFF') }}`, - }; - } - if (svc.intf?.includes('evt.lvl.report')) { components[`${svc.addr}_lvl`] = { unique_id: `${svc.addr}_lvl`, platform: 'sensor', + entity_category: 'diagnostic', device_class: 'battery', unit_of_measurement: svc.props?.sup_units?.[0] ?? '%', value_template: `{{ value_json['${svc.addr}'].lvl }}`, }; + } else if (svc.intf?.includes('evt.alarm.report')) { + components[`${svc.addr}_alarm`] = { + unique_id: `${svc.addr}_alarm`, + platform: 'binary_sensor', + entity_category: 'diagnostic', + device_class: 'battery', + value_template: `{{ (value_json['${svc.addr}'].alarm.status == 'activ') | iif('ON', 'OFF') }}`, + }; } return {