From 485ce7b784316ea51eb12c29195ab2a13750a648 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 6 Oct 2013 17:20:27 -0700 Subject: [PATCH] Added events to control the lights via the event bus --- homeassistant/actors.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/homeassistant/actors.py b/homeassistant/actors.py index fe4004dea71..04b94d8c17e 100644 --- a/homeassistant/actors.py +++ b/homeassistant/actors.py @@ -22,6 +22,8 @@ LIGHT_TRANSITION_TIME = timedelta(minutes=15) HUE_MAX_TRANSITION_TIME = 9000 +EVENT_TURN_LIGHT_ON = "turn_light_on" +EVENT_TURN_LIGHT_OFF = "turn_light_off" def _hue_process_transition_time(transition_seconds): """ Transition time is in 1/10th seconds and cannot exceed MAX_TRANSITION_TIME. """ @@ -52,6 +54,13 @@ class LightTrigger(object): if statemachine.is_state(STATE_CATEGORY_SUN, SUN_STATE_ABOVE_HORIZON): self._handle_sun_rising(None, None, None) + # Listen for light on and light off events + eventbus.listen(EVENT_TURN_LIGHT_ON, lambda event: self.light_control.turn_light_on(event.data.get("light_id", None), + event.data.get("transition_seconds", None))) + + eventbus.listen(EVENT_TURN_LIGHT_OFF, lambda event: self.light_control.turn_light_off(event.data.get("light_id", None), + event.data.get("transition_seconds", None))) + def _handle_sun_rising(self, category, old_state, new_state): """The moment sun sets we want to have all the lights on.