Optimize yeelight signal handling (#22806)
This commit is contained in:
parent
a91e79ee77
commit
f62d1d8d09
3 changed files with 12 additions and 10 deletions
|
@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
DOMAIN = "yeelight"
|
||||
DATA_YEELIGHT = DOMAIN
|
||||
DATA_UPDATED = '{}_data_updated'.format(DOMAIN)
|
||||
DATA_UPDATED = 'yeelight_{}_data_updated'
|
||||
|
||||
DEFAULT_NAME = 'Yeelight'
|
||||
DEFAULT_TRANSITION = 350
|
||||
|
@ -274,4 +274,4 @@ class YeelightDevice:
|
|||
_LOGGER.error("Unable to update bulb status: %s", ex)
|
||||
self._available = False
|
||||
|
||||
dispatcher_send(self._hass, DATA_UPDATED, self._ipaddr)
|
||||
dispatcher_send(self._hass, DATA_UPDATED.format(self._ipaddr))
|
||||
|
|
|
@ -31,14 +31,15 @@ class YeelightNightlightModeSensor(BinarySensorDevice):
|
|||
self._device = device
|
||||
|
||||
@callback
|
||||
def _schedule_immediate_update(self, ipaddr):
|
||||
if ipaddr == self._device.ipaddr:
|
||||
self.async_schedule_update_ha_state()
|
||||
def _schedule_immediate_update(self):
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Handle entity which will be added."""
|
||||
async_dispatcher_connect(
|
||||
self.hass, DATA_UPDATED, self._schedule_immediate_update
|
||||
self.hass,
|
||||
DATA_UPDATED.format(self._device.ipaddr),
|
||||
self._schedule_immediate_update
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -212,14 +212,15 @@ class YeelightLight(Light):
|
|||
self._custom_effects = {}
|
||||
|
||||
@callback
|
||||
def _schedule_immediate_update(self, ipaddr):
|
||||
if ipaddr == self.device.ipaddr:
|
||||
self.async_schedule_update_ha_state(True)
|
||||
def _schedule_immediate_update(self):
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Handle entity which will be added."""
|
||||
async_dispatcher_connect(
|
||||
self.hass, DATA_UPDATED, self._schedule_immediate_update
|
||||
self.hass,
|
||||
DATA_UPDATED.format(self._device.ipaddr),
|
||||
self._schedule_immediate_update
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue