Fix status of lutron switches/lights after HA reboot (#25592)

pull/25601/head
Jon Gilmore 2019-07-30 22:48:43 -05:00 committed by Martin Hjelmare
parent ffe6ddeba7
commit 1e8a4dd0bc
2 changed files with 11 additions and 0 deletions

View File

@ -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)

View File

@ -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