mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Do not use zha default light polling (#22513)
* don't use default light polling * review comment
This commit is contained in:
parent
9f72764cff
commit
173ef7cac5
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user