Skip to content

Commit ecc9909

Browse files
authored
Update sensor.py
Fix wrong EVU time calculation
1 parent fde3dd2 commit ecc9909

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

custom_components/luxtronik/sensor.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,18 @@ def _handle_coordinator_update(
224224
# evu start
225225
if (
226226
self._attr_cache[SA.EVU_FIRST_START_TIME] == time.min
227-
or time_now.hour <= self._attr_cache[SA.EVU_FIRST_START_TIME].hour
228227
or (
229-
self._attr_cache[SA.EVU_SECOND_START_TIME] != time.min
230-
and time_now.hour < self._attr_cache[SA.EVU_SECOND_START_TIME].hour
228+
time_now.hour <= self._attr_cache[SA.EVU_FIRST_START_TIME].hour
229+
or (
230+
self._attr_cache[SA.EVU_SECOND_START_TIME] != time.min
231+
and time_now.hour < self._attr_cache[SA.EVU_SECOND_START_TIME].hour
232+
)
233+
or time_now.hour <= self._attr_cache[SA.EVU_FIRST_END_TIME].hour
234+
)
235+
and (
236+
self._attr_cache[SA.EVU_FIRST_END_TIME].hour > time_now.hour
237+
or self._attr_cache[SA.EVU_FIRST_END_TIME] == time.min
231238
)
232-
or time_now.hour <= self._attr_cache[SA.EVU_FIRST_END_TIME].hour
233239
):
234240
self._attr_cache[SA.EVU_FIRST_START_TIME] = time_now
235241
else:

0 commit comments

Comments
 (0)