Do not use zha default light polling (#22513)

* don't use default light polling

* review comment
pull/22539/head
David F. Mulcahey 2019-03-29 11:52:13 -04:00 committed by Martin Hjelmare
parent 1050baa9cc
commit 6dc127780e
1 changed files with 6 additions and 5 deletions

View File

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