From 8832e3b35de27ea688218e6edb3d4041cfe7a51b Mon Sep 17 00:00:00 2001 From: Dominik Amann Date: Wed, 16 Oct 2024 23:42:03 +0200 Subject: [PATCH] Fix pump conversion if value is string --- custom_components/oekofen_pellematic_compact/sensor.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/custom_components/oekofen_pellematic_compact/sensor.py b/custom_components/oekofen_pellematic_compact/sensor.py index c918e9d..a714de0 100644 --- a/custom_components/oekofen_pellematic_compact/sensor.py +++ b/custom_components/oekofen_pellematic_compact/sensor.py @@ -544,6 +544,11 @@ def _update_state(self): current_value = int(current_value) / 10 else: current_value = int(current_value) / 10000 + if self._attr_device_class == SensorDeviceClass.POWER_FACTOR: + if current_value == 'true': + current_value = 100 + elif current_value == 'false': + current_value = 0 except: try: current_value = self._hub.data[self._prefix][self._key.replace("#2", "")] @@ -557,6 +562,11 @@ def _update_state(self): current_value = int(current_value) / 10 else: current_value = int(current_value) / 10000 + if self._attr_device_class == SensorDeviceClass.POWER_FACTOR: + if current_value == 'true': + current_value = 100 + elif current_value == 'false': + current_value = 0 except: self._state = current_value self._state = current_value