From ecc9909b5756a922d886bb66709efc9106e1c92c Mon Sep 17 00:00:00 2001 From: BenPru <32298537+BenPru@users.noreply.github.com> Date: Fri, 15 Nov 2024 22:08:55 +0100 Subject: [PATCH] Update sensor.py Fix wrong EVU time calculation --- custom_components/luxtronik/sensor.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/custom_components/luxtronik/sensor.py b/custom_components/luxtronik/sensor.py index 163205e..09b7d61 100644 --- a/custom_components/luxtronik/sensor.py +++ b/custom_components/luxtronik/sensor.py @@ -224,12 +224,18 @@ def _handle_coordinator_update( # evu start if ( self._attr_cache[SA.EVU_FIRST_START_TIME] == time.min - or time_now.hour <= self._attr_cache[SA.EVU_FIRST_START_TIME].hour or ( - self._attr_cache[SA.EVU_SECOND_START_TIME] != time.min - and time_now.hour < self._attr_cache[SA.EVU_SECOND_START_TIME].hour + time_now.hour <= self._attr_cache[SA.EVU_FIRST_START_TIME].hour + or ( + self._attr_cache[SA.EVU_SECOND_START_TIME] != time.min + and time_now.hour < self._attr_cache[SA.EVU_SECOND_START_TIME].hour + ) + or time_now.hour <= self._attr_cache[SA.EVU_FIRST_END_TIME].hour + ) + and ( + self._attr_cache[SA.EVU_FIRST_END_TIME].hour > time_now.hour + or self._attr_cache[SA.EVU_FIRST_END_TIME] == time.min ) - or time_now.hour <= self._attr_cache[SA.EVU_FIRST_END_TIME].hour ): self._attr_cache[SA.EVU_FIRST_START_TIME] = time_now else: