From 6bf35232b92fed39e7d0e7ac7255a3458458bc7f Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Sat, 17 Aug 2019 14:50:15 -0700 Subject: [PATCH] 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. --- homeassistant/components/lutron/light.py | 2 -- homeassistant/components/lutron/switch.py | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/lutron/light.py b/homeassistant/components/lutron/light.py index 138d4882446..cae2fc5cfdd 100644 --- a/homeassistant/components/lutron/light.py +++ b/homeassistant/components/lutron/light.py @@ -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) diff --git a/homeassistant/components/lutron/switch.py b/homeassistant/components/lutron/switch.py index 7aa5334cbf2..604f19fc2ae 100644 --- a/homeassistant/components/lutron/switch.py +++ b/homeassistant/components/lutron/switch.py @@ -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