From bca41596819ed3c3f44c3e25569e46b0fff0213c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Mon, 6 Jan 2025 17:33:58 +0000 Subject: [PATCH] fix: support OFF for SystemStatus #168 --- custom_components/idm_heatpump/const.py | 1 + custom_components/idm_heatpump/sensor_addresses.py | 3 ++- custom_components/idm_heatpump/services.yaml | 1 + custom_components/idm_heatpump/translations/de.json | 1 + custom_components/idm_heatpump/translations/en.json | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/idm_heatpump/const.py b/custom_components/idm_heatpump/const.py index e8a7a01..cb931a1 100644 --- a/custom_components/idm_heatpump/const.py +++ b/custom_components/idm_heatpump/const.py @@ -117,6 +117,7 @@ def _missing_(cls, value) -> Any: class SystemStatus(_SensorEnum): """IDM heat pump system status.""" + OFF = 0xFFFF STANDBY = 0 AUTOMATIC = 1 AWAY = 2 diff --git a/custom_components/idm_heatpump/sensor_addresses.py b/custom_components/idm_heatpump/sensor_addresses.py index f7be785..f6a3f9e 100644 --- a/custom_components/idm_heatpump/sensor_addresses.py +++ b/custom_components/idm_heatpump/sensor_addresses.py @@ -298,7 +298,8 @@ def datatype(self) -> ModbusClientMixin.DATATYPE: def decode(self, registers: list[int]) -> tuple[bool, _EnumT]: value = self._decode_raw(registers) LOGGER.debug("raw value (uint16) for %s: %d", self.name, value) - if value == 0xFFFF: + + if value == 0xFFFF and 0xFFFF not in list(map(int, self.enum)): # special case: unavailable return (False, self.enum(None)) diff --git a/custom_components/idm_heatpump/services.yaml b/custom_components/idm_heatpump/services.yaml index 62e3a43..c8bbb5f 100644 --- a/custom_components/idm_heatpump/services.yaml +++ b/custom_components/idm_heatpump/services.yaml @@ -171,6 +171,7 @@ set_system_status: selector: select: options: + - off - standby - automatic - away diff --git a/custom_components/idm_heatpump/translations/de.json b/custom_components/idm_heatpump/translations/de.json index 6d36117..4eff8bb 100644 --- a/custom_components/idm_heatpump/translations/de.json +++ b/custom_components/idm_heatpump/translations/de.json @@ -268,6 +268,7 @@ }, "system_status_options": { "options": { + "off": "Komplett Aus (kein Frostschutz)", "standby": "Standby", "automatic": "Automatik", "away": "Abwesend", diff --git a/custom_components/idm_heatpump/translations/en.json b/custom_components/idm_heatpump/translations/en.json index 8d3f0c6..508484f 100644 --- a/custom_components/idm_heatpump/translations/en.json +++ b/custom_components/idm_heatpump/translations/en.json @@ -268,6 +268,7 @@ }, "system_status_options": { "options": { + "off": "Off (no freeze protection)", "standby": "Standby", "automatic": "Automatic", "away": "Away",