From ef2da07e147c4df27dcda1ba28f4619bd9c71c89 Mon Sep 17 00:00:00 2001 From: Efipso Date: Sun, 18 Aug 2024 20:09:00 +0200 Subject: [PATCH] Changed Error State Entity Category + Added Error Message Sensor --- README.md | 5 +++++ .../melcloud_custom/binary_sensor.py | 4 +++- custom_components/melcloud_custom/icons.json | 16 ++++++++++++---- custom_components/melcloud_custom/manifest.json | 2 +- custom_components/melcloud_custom/sensor.py | 17 +++++++++++++++++ .../melcloud_custom/translations/en.json | 3 +++ info.md | 5 +++++ 7 files changed, 46 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7910c5a..800d90a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ It's done basically for my own use. ## Changelog +v1.4 +- Added Error Message sensor +- Changed Error State Entity Category +- Changed WIFI Signal Strength Entity Category + v1.3 - Added Error State sensor diff --git a/custom_components/melcloud_custom/binary_sensor.py b/custom_components/melcloud_custom/binary_sensor.py index 2df3a6f..f4fee30 100644 --- a/custom_components/melcloud_custom/binary_sensor.py +++ b/custom_components/melcloud_custom/binary_sensor.py @@ -12,7 +12,7 @@ BinarySensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry - +from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -34,6 +34,7 @@ class MelcloudBinarySensorEntityDescription(BinarySensorEntityDescription): key="error_state", translation_key="error_state", device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda x: x.device.has_error, enabled=lambda x: True, ), @@ -43,6 +44,7 @@ class MelcloudBinarySensorEntityDescription(BinarySensorEntityDescription): key="error_state", translation_key="error_state", device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda x: x.device.has_error, enabled=lambda x: True, ), diff --git a/custom_components/melcloud_custom/icons.json b/custom_components/melcloud_custom/icons.json index f7279a0..3850ccc 100644 --- a/custom_components/melcloud_custom/icons.json +++ b/custom_components/melcloud_custom/icons.json @@ -12,11 +12,19 @@ }, "wifi_signal": { "default": "mdi:wifi" + }, + "error_message": { + "default": "mdi:message-alert" + } + }, + "binary_sensor": { + "error_state": { + "default": "mdi:alert" } + }, + "services": { + "set_vane_horizontal": "mdi:arrow-left-right", + "set_vane_vertical": "mdi:arrow-up-down" } - }, - "services": { - "set_vane_horizontal": "mdi:arrow-left-right", - "set_vane_vertical": "mdi:arrow-up-down" } } \ No newline at end of file diff --git a/custom_components/melcloud_custom/manifest.json b/custom_components/melcloud_custom/manifest.json index e8ebf2d..58c772b 100644 --- a/custom_components/melcloud_custom/manifest.json +++ b/custom_components/melcloud_custom/manifest.json @@ -8,5 +8,5 @@ "documentation": "https://github.com/efipso/melcloud", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/efipso/melcloud/issues", - "version": "1.3" + "version": "1.4" } \ No newline at end of file diff --git a/custom_components/melcloud_custom/sensor.py b/custom_components/melcloud_custom/sensor.py index 907fdb6..dfceb58 100644 --- a/custom_components/melcloud_custom/sensor.py +++ b/custom_components/melcloud_custom/sensor.py @@ -17,6 +17,7 @@ SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfEnergy, UnitOfTemperature, + EntityCategory, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -69,10 +70,18 @@ class MelcloudSensorEntityDescription(SensorEntityDescription): native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, device_class=SensorDeviceClass.SIGNAL_STRENGTH, state_class=SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda x: x.device.wifi_signal, enabled=lambda x: True, entity_registry_enabled_default=False, ), + MelcloudSensorEntityDescription( + key="error_message", + translation_key="error_message", + entity_category=EntityCategory.DIAGNOSTIC, + value_fn=lambda x: x.device.error_code if x.device.has_error else 'No error', + enabled=lambda x: True, + ), ) ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = ( MelcloudSensorEntityDescription( @@ -99,10 +108,18 @@ class MelcloudSensorEntityDescription(SensorEntityDescription): native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, device_class=SensorDeviceClass.SIGNAL_STRENGTH, state_class=SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda x: x.device.wifi_signal, enabled=lambda x: True, entity_registry_enabled_default=False, ), + MelcloudSensorEntityDescription( + key="error_message", + translation_key="error_message", + entity_category=EntityCategory.DIAGNOSTIC, + value_fn=lambda x: x.device.error_code if x.device.has_error else 'No error', + enabled=lambda x: True, + ), ) ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = ( MelcloudSensorEntityDescription( diff --git a/custom_components/melcloud_custom/translations/en.json b/custom_components/melcloud_custom/translations/en.json index c563a20..3356c35 100644 --- a/custom_components/melcloud_custom/translations/en.json +++ b/custom_components/melcloud_custom/translations/en.json @@ -90,6 +90,9 @@ }, "wifi_signal": { "name": "Wifi Signal Strength" + }, + "error_message": { + "name": "Error Message" } }, "binary_sensor": { diff --git a/info.md b/info.md index 7910c5a..800d90a 100644 --- a/info.md +++ b/info.md @@ -15,6 +15,11 @@ It's done basically for my own use. ## Changelog +v1.4 +- Added Error Message sensor +- Changed Error State Entity Category +- Changed WIFI Signal Strength Entity Category + v1.3 - Added Error State sensor