From 012baaf96ba86f9f9c06c69c6409f0703af8d394 Mon Sep 17 00:00:00 2001 From: skurz Date: Wed, 9 Oct 2024 22:51:22 +0200 Subject: [PATCH 1/4] restore evu dates attribute correctly --- custom_components/luxtronik/sensor.py | 37 ++++++++++++++++++--------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/custom_components/luxtronik/sensor.py b/custom_components/luxtronik/sensor.py index 2480a94..1b4e60c 100644 --- a/custom_components/luxtronik/sensor.py +++ b/custom_components/luxtronik/sensor.py @@ -216,6 +216,8 @@ def _handle_coordinator_update( time_now = time(datetime.now().hour, datetime.now().minute) evu = LuxOperationMode.evu.value weekday = datetime.today().weekday() + if not isinstance(self._attr_cache[SA.EVU_DAYS], list): + self._attr_cache[SA.EVU_DAYS] = list() if self._attr_native_value is None or self._last_state is None: pass elif self._attr_native_value == evu and str(self._last_state) != evu: @@ -394,16 +396,18 @@ def _calc_next_evu_event_minutes(self) -> int | None: return None evu_hours = (24 if evu_time < time_now else 0) + evu_time.hour weekday = datetime.today().weekday() + if not isinstance(self._attr_cache[SA.EVU_DAYS], list): + self._attr_cache[SA.EVU_DAYS] = list() evu_pause = 0 if not self._attr_cache[SA.EVU_DAYS] and weekday not in self._attr_cache[SA.EVU_DAYS]: - evu_pause += (24 - datetime.now().hour)*60 - datetime.now().minute - for i in range(1, 7): - if weekday+i > 6: - i = -7+i - if weekday+i in self._attr_cache[SA.EVU_DAYS]: - return (evu_hours - time_now.hour) * 60 + evu_time.minute - time_now.minute + evu_pause - else: - evu_pause += 1440 + evu_pause += (24 - datetime.now().hour)*60 - datetime.now().minute + for i in range(1, 7): + if weekday+i > 6: + i = -7+i + if weekday+i in self._attr_cache[SA.EVU_DAYS]: + return (evu_hours - time_now.hour) * 60 + evu_time.minute - time_now.minute + evu_pause + else: + evu_pause += 1440 else: return (evu_hours - time_now.hour) * 60 + evu_time.minute - time_now.minute @@ -445,10 +449,19 @@ def _wd_txt(self, value: list) -> str: return ','.join(days) def _restore_attr_value(self, value: Any | None) -> Any: - if value is None or ":" not in str(value): - return time.min - vals = str(value).split(":") - return time(int(vals[0]), int(vals[1])) + if value is not None: + if ',' in str(value): + vals = list() + for day in str(value).split(","): + for idx, name in enumerate(calendar.day_name): + if day == name: + vals.append(idx) + break + return vals + if ":" in str(value): + vals = str(value).split(":") + return time(int(vals[0]), int(vals[1])) + return time.min class LuxtronikIndexSensor(LuxtronikSensorEntity, SensorEntity): From 2afb44c1f60800f07daff503475cf010708fb079 Mon Sep 17 00:00:00 2001 From: skurz Date: Thu, 10 Oct 2024 00:20:55 +0200 Subject: [PATCH 2/4] restore single day entries --- custom_components/luxtronik/sensor.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/custom_components/luxtronik/sensor.py b/custom_components/luxtronik/sensor.py index 1b4e60c..ab7b8da 100644 --- a/custom_components/luxtronik/sensor.py +++ b/custom_components/luxtronik/sensor.py @@ -449,18 +449,18 @@ def _wd_txt(self, value: list) -> str: return ','.join(days) def _restore_attr_value(self, value: Any | None) -> Any: - if value is not None: - if ',' in str(value): - vals = list() - for day in str(value).split(","): - for idx, name in enumerate(calendar.day_name): - if day == name: - vals.append(idx) - break - return vals + if value is not None: if ":" in str(value): vals = str(value).split(":") return time(int(vals[0]), int(vals[1])) + vals = list() + for day in str(value).split(","): + for idx, name in enumerate(calendar.day_name): + if day == name: + vals.append(idx) + break + if len(vals): + return vals return time.min From 31bb5ed283f9e4d46b12e99dbd4ff38117095ca2 Mon Sep 17 00:00:00 2001 From: skurz Date: Thu, 31 Oct 2024 13:11:38 +0100 Subject: [PATCH 3/4] add min firmware version for current power consumption sensor --- custom_components/luxtronik/sensor.py | 2 +- custom_components/luxtronik/sensor_entities_predefined.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/luxtronik/sensor.py b/custom_components/luxtronik/sensor.py index ab7b8da..335136c 100644 --- a/custom_components/luxtronik/sensor.py +++ b/custom_components/luxtronik/sensor.py @@ -459,7 +459,7 @@ def _restore_attr_value(self, value: Any | None) -> Any: if day == name: vals.append(idx) break - if len(vals): + if vals: return vals return time.min diff --git a/custom_components/luxtronik/sensor_entities_predefined.py b/custom_components/luxtronik/sensor_entities_predefined.py index a00300e..9b61067 100644 --- a/custom_components/luxtronik/sensor_entities_predefined.py +++ b/custom_components/luxtronik/sensor_entities_predefined.py @@ -468,6 +468,7 @@ native_unit_of_measurement=UnitOfPower.WATT, entity_registry_enabled_default=False, native_precision=0, + min_firmware_version_minor=FirmwareVersionMinor.minor_88, ), # endregion Main heatpump # region Heating From 7346b2086c9e0ee5a0ceb21311f48e2fa7067ed8 Mon Sep 17 00:00:00 2001 From: skurz Date: Fri, 8 Nov 2024 18:10:36 +0100 Subject: [PATCH 4/4] convert evu_days of type string to list --- custom_components/luxtronik/sensor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/luxtronik/sensor.py b/custom_components/luxtronik/sensor.py index 335136c..163205e 100644 --- a/custom_components/luxtronik/sensor.py +++ b/custom_components/luxtronik/sensor.py @@ -396,8 +396,10 @@ def _calc_next_evu_event_minutes(self) -> int | None: return None evu_hours = (24 if evu_time < time_now else 0) + evu_time.hour weekday = datetime.today().weekday() - if not isinstance(self._attr_cache[SA.EVU_DAYS], list): - self._attr_cache[SA.EVU_DAYS] = list() + if isinstance(self._attr_cache[SA.EVU_DAYS], str): + self._attr_cache[SA.EVU_DAYS] = self._attr_cache[SA.EVU_DAYS].split(',') + elif not isinstance(self._attr_cache[SA.EVU_DAYS], list): + self._attr_cache[SA.EVU_DAYS] = list() evu_pause = 0 if not self._attr_cache[SA.EVU_DAYS] and weekday not in self._attr_cache[SA.EVU_DAYS]: evu_pause += (24 - datetime.now().hour)*60 - datetime.now().minute