mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Fix status of lutron switches/lights after HA reboot (#25592)
This commit is contained in:
parent
ffe6ddeba7
commit
1e8a4dd0bc
@ -35,6 +35,7 @@ class LutronLight(LutronDevice, Light):
|
|||||||
def __init__(self, area_name, lutron_device, controller):
|
def __init__(self, area_name, lutron_device, controller):
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
self._prev_brightness = None
|
self._prev_brightness = None
|
||||||
|
self._is_on = False
|
||||||
super().__init__(area_name, lutron_device, controller)
|
super().__init__(area_name, lutron_device, controller)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -78,5 +79,6 @@ class LutronLight(LutronDevice, Light):
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Call when forcing a refresh of the device."""
|
"""Call when forcing a refresh of the device."""
|
||||||
|
self._is_on = self._lutron_device.level > 0
|
||||||
if self._prev_brightness is None:
|
if self._prev_brightness is None:
|
||||||
self._prev_brightness = to_hass_level(self._lutron_device.level)
|
self._prev_brightness = to_hass_level(self._lutron_device.level)
|
||||||
|
@ -21,6 +21,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
class LutronSwitch(LutronDevice, SwitchDevice):
|
class LutronSwitch(LutronDevice, SwitchDevice):
|
||||||
"""Representation of a Lutron Switch."""
|
"""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):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
self._lutron_device.level = 100
|
self._lutron_device.level = 100
|
||||||
@ -40,3 +45,7 @@ class LutronSwitch(LutronDevice, SwitchDevice):
|
|||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
return self._lutron_device.last_level() > 0
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user