mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47: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
1050baa9cc
commit
6dc127780e
@ -11,6 +11,7 @@ from homeassistant.components import light
|
|||||||
from homeassistant.const import STATE_ON
|
from homeassistant.const import STATE_ON
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
from .const import (
|
from .const import (
|
||||||
DATA_ZHA, DATA_ZHA_DISPATCHERS, ZHA_DISCOVERY_NEW, COLOR_CHANNEL,
|
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._supported_features |= light.SUPPORT_COLOR
|
||||||
self._hs_color = (0, 0)
|
self._hs_color = (0, 0)
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self) -> bool:
|
|
||||||
"""Poll state from device."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if entity is on."""
|
"""Return true if entity is on."""
|
||||||
@ -157,6 +153,7 @@ class Light(ZhaEntity, light.Light):
|
|||||||
if self._level_channel:
|
if self._level_channel:
|
||||||
await self.async_accept_signal(
|
await self.async_accept_signal(
|
||||||
self._level_channel, SIGNAL_SET_LEVEL, self.set_level)
|
self._level_channel, SIGNAL_SET_LEVEL, self.set_level)
|
||||||
|
async_track_time_interval(self.hass, self.refresh, SCAN_INTERVAL)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_restore_last_state(self, last_state):
|
def async_restore_last_state(self, last_state):
|
||||||
@ -247,3 +244,7 @@ class Light(ZhaEntity, light.Light):
|
|||||||
if self._level_channel:
|
if self._level_channel:
|
||||||
self._brightness = await self._level_channel.get_attribute_value(
|
self._brightness = await self._level_channel.get_attribute_value(
|
||||||
'current_level')
|
'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