Skip to content

Commit

Permalink
Zone switch entity doesn't need to listen to all events
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr committed Jul 12, 2020
1 parent 75f0ff4 commit b85dcee
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions custom_components/bhyve/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ def _set_watering_program(self, program):
}
)

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

def _on_ws_data(self, data):
"""
{'event': 'watering_in_progress_notification', 'program': 'e', 'current_station': 1, 'run_time': 14, 'started_watering_station_at': '2020-01-09T20:29:59.000Z', 'rain_sensor_hold': False, 'device_id': 'id', 'timestamp': '2020-01-09T20:29:59.000Z'}
Expand All @@ -449,10 +458,7 @@ def _on_ws_data(self, data):
{'event': 'program_changed' }
"""
event = data.get("event")
if event is None:
_LOGGER.warning("No event on ws data {}".format(data))
return
elif event == EVENT_DEVICE_IDLE or event == EVENT_WATERING_COMPLETE:
if event == EVENT_DEVICE_IDLE or event == EVENT_WATERING_COMPLETE:
self._is_on = False
self._set_watering_started(None)
elif event == EVENT_WATERING_IN_PROGRESS:
Expand Down

0 comments on commit b85dcee

Please sign in to comment.