Don't force a query to the main lutron repeater on update (#25939)

We only want to force a query if we don't have any previous state.
Otherwise, we should be tracking the state via continuous status
updates.

For lights (not switches) the extra query was also superfluous since
it was already querying on startup.

We should probably have a timeout on that so at some point we'll
requery in case remote end disconnected/rebooted, etc. Leaving for
another PR.
This commit is contained in:
Dima Zavin 2019-08-17 14:50:15 -07:00 committed by Martin Hjelmare
parent 9dff2e188b
commit 6bf35232b9
2 changed files with 3 additions and 4 deletions

View File

@ -34,7 +34,6 @@ 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,6 +77,5 @@ 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

@ -23,7 +23,7 @@ class LutronSwitch(LutronDevice, SwitchDevice):
def __init__(self, area_name, lutron_device, controller):
"""Initialize the switch."""
self._is_on = False
self._prev_state = None
super().__init__(area_name, lutron_device, controller)
def turn_on(self, **kwargs):
@ -48,4 +48,5 @@ class LutronSwitch(LutronDevice, SwitchDevice):
def update(self):
"""Call when forcing a refresh of the device."""
self._is_on = self._lutron_device.level > 0
if self._prev_state is None:
self._prev_state = self._lutron_device.level > 0