Skip to content

Commit

Permalink
Fix area sensor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerhp committed Nov 9, 2022
1 parent 3d22690 commit 310b963
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions custom_components/load_shedding/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,17 @@ def native_value(self) -> StateType:
if ATTR_END_TIME in event and event.get(ATTR_END_TIME) < now:
continue

self._attr_native_value = cast(StateType, STATE_OFF)
if event.get(ATTR_STAGE) == Stage.NO_LOAD_SHEDDING:
return self._attr_native_value
if event.get(ATTR_START_TIME) <= now <= event.get(ATTR_END_TIME):
self._attr_native_value = cast(StateType, STATE_ON)
break

if event.get(ATTR_START_TIME) > now:
self._attr_native_value = cast(StateType, STATE_OFF)
break

if event.get(ATTR_STAGE) == Stage.NO_LOAD_SHEDDING:
self._attr_native_value = cast(StateType, STATE_OFF)
break

return self._attr_native_value

Expand Down

0 comments on commit 310b963

Please sign in to comment.