From 6dc127780ebffbdd439a3c3b59fa6e524b7882d9 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Fri, 29 Mar 2019 11:52:13 -0400 Subject: [PATCH] Do not use zha default light polling (#22513) * don't use default light polling * review comment --- homeassistant/components/zha/light.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index 8b2cd349b9d..6ba4efa9b0f 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -11,6 +11,7 @@ from homeassistant.components import light from homeassistant.const import STATE_ON from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.event import async_track_time_interval import homeassistant.util.color as color_util from .const import ( DATA_ZHA, DATA_ZHA_DISPATCHERS, ZHA_DISCOVERY_NEW, COLOR_CHANNEL, @@ -96,11 +97,6 @@ class Light(ZhaEntity, light.Light): self._supported_features |= light.SUPPORT_COLOR self._hs_color = (0, 0) - @property - def should_poll(self) -> bool: - """Poll state from device.""" - return True - @property def is_on(self) -> bool: """Return true if entity is on.""" @@ -157,6 +153,7 @@ class Light(ZhaEntity, light.Light): if self._level_channel: await self.async_accept_signal( self._level_channel, SIGNAL_SET_LEVEL, self.set_level) + async_track_time_interval(self.hass, self.refresh, SCAN_INTERVAL) @callback def async_restore_last_state(self, last_state): @@ -247,3 +244,7 @@ class Light(ZhaEntity, light.Light): if self._level_channel: self._brightness = await self._level_channel.get_attribute_value( 'current_level') + + async def refresh(self, time): + """Call async_update at an interval.""" + await self.async_update()