From 1e8a4dd0bc4338aab571247f1d447142f3c74741 Mon Sep 17 00:00:00 2001 From: Jon Gilmore <7232986+JonGilmore@users.noreply.github.com> Date: Tue, 30 Jul 2019 22:48:43 -0500 Subject: [PATCH] Fix status of lutron switches/lights after HA reboot (#25592) --- homeassistant/components/lutron/light.py | 2 ++ homeassistant/components/lutron/switch.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/homeassistant/components/lutron/light.py b/homeassistant/components/lutron/light.py index 6ddf54e1fc1..9f488b07898 100644 --- a/homeassistant/components/lutron/light.py +++ b/homeassistant/components/lutron/light.py @@ -35,6 +35,7 @@ class LutronLight(LutronDevice, Light): def __init__(self, area_name, lutron_device, controller): """Initialize the light.""" self._prev_brightness = None + self._is_on = False super().__init__(area_name, lutron_device, controller) @property @@ -78,5 +79,6 @@ class LutronLight(LutronDevice, Light): def update(self): """Call when forcing a refresh of the device.""" + self._is_on = self._lutron_device.level > 0 if self._prev_brightness is None: self._prev_brightness = to_hass_level(self._lutron_device.level) diff --git a/homeassistant/components/lutron/switch.py b/homeassistant/components/lutron/switch.py index 0b1705fb235..f54e2d3e999 100644 --- a/homeassistant/components/lutron/switch.py +++ b/homeassistant/components/lutron/switch.py @@ -21,6 +21,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None): class LutronSwitch(LutronDevice, SwitchDevice): """Representation of a Lutron Switch.""" + def __init__(self, area_name, lutron_device, controller): + """Initialize the switch.""" + self._is_on = False + super().__init__(area_name, lutron_device, controller) + def turn_on(self, **kwargs): """Turn the switch on.""" self._lutron_device.level = 100 @@ -40,3 +45,7 @@ class LutronSwitch(LutronDevice, SwitchDevice): def is_on(self): """Return true if device is on.""" return self._lutron_device.last_level() > 0 + + def update(self): + """Call when forcing a refresh of the device.""" + self._is_on = self._lutron_device.level > 0