mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Optimize yeelight signal handling (#22806)
This commit is contained in:
parent
a91e79ee77
commit
f62d1d8d09
@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
DOMAIN = "yeelight"
|
DOMAIN = "yeelight"
|
||||||
DATA_YEELIGHT = DOMAIN
|
DATA_YEELIGHT = DOMAIN
|
||||||
DATA_UPDATED = '{}_data_updated'.format(DOMAIN)
|
DATA_UPDATED = 'yeelight_{}_data_updated'
|
||||||
|
|
||||||
DEFAULT_NAME = 'Yeelight'
|
DEFAULT_NAME = 'Yeelight'
|
||||||
DEFAULT_TRANSITION = 350
|
DEFAULT_TRANSITION = 350
|
||||||
@ -274,4 +274,4 @@ class YeelightDevice:
|
|||||||
_LOGGER.error("Unable to update bulb status: %s", ex)
|
_LOGGER.error("Unable to update bulb status: %s", ex)
|
||||||
self._available = False
|
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
|
self._device = device
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _schedule_immediate_update(self, ipaddr):
|
def _schedule_immediate_update(self):
|
||||||
if ipaddr == self._device.ipaddr:
|
self.async_schedule_update_ha_state()
|
||||||
self.async_schedule_update_ha_state()
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Handle entity which will be added."""
|
"""Handle entity which will be added."""
|
||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
self.hass, DATA_UPDATED, self._schedule_immediate_update
|
self.hass,
|
||||||
|
DATA_UPDATED.format(self._device.ipaddr),
|
||||||
|
self._schedule_immediate_update
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -212,14 +212,15 @@ class YeelightLight(Light):
|
|||||||
self._custom_effects = {}
|
self._custom_effects = {}
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _schedule_immediate_update(self, ipaddr):
|
def _schedule_immediate_update(self):
|
||||||
if ipaddr == self.device.ipaddr:
|
self.async_schedule_update_ha_state(True)
|
||||||
self.async_schedule_update_ha_state(True)
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Handle entity which will be added."""
|
"""Handle entity which will be added."""
|
||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
self.hass, DATA_UPDATED, self._schedule_immediate_update
|
self.hass,
|
||||||
|
DATA_UPDATED.format(self._device.ipaddr),
|
||||||
|
self._schedule_immediate_update
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user