Skip to content

Commit

Permalink
Experimental change to turn switch off after receiving a change mode …
Browse files Browse the repository at this point in the history
…event. cc #96
  • Loading branch information
sebr committed Feb 12, 2022
1 parent aec6447 commit c509eab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions custom_components/bhyve/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,12 @@ def _set_watering_program(self, program):

def _should_handle_event(self, event_name, data):
return event_name in [
EVENT_CHANGE_MODE,
EVENT_DEVICE_IDLE,
EVENT_PROGRAM_CHANGED,
EVENT_SET_MANUAL_PRESET_TIME,
EVENT_WATERING_COMPLETE,
EVENT_WATERING_IN_PROGRESS,
EVENT_SET_MANUAL_PRESET_TIME,
EVENT_PROGRAM_CHANGED,
]

def _on_ws_data(self, data):
Expand All @@ -480,7 +481,9 @@ def _on_ws_data(self, data):
# {'event': 'program_changed' }

event = data.get("event")
if event in (EVENT_DEVICE_IDLE, EVENT_WATERING_COMPLETE):
if event in (EVENT_DEVICE_IDLE, EVENT_WATERING_COMPLETE) or (
event == EVENT_CHANGE_MODE and event.get("mode") in ("off", "auto")
):
self._is_on = False
self._set_watering_started(None)
elif event == EVENT_WATERING_IN_PROGRESS:
Expand Down

0 comments on commit c509eab

Please sign in to comment.