Wait for yeelight internal state to change before update after on/off (#56795)
parent
25ce7f951a
commit
23cbd9075a
|
@ -1,6 +1,7 @@
|
|||
"""Light platform support for yeelight."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import math
|
||||
|
||||
|
@ -209,6 +210,9 @@ SERVICE_SCHEMA_SET_AUTO_DELAY_OFF_SCENE = {
|
|||
}
|
||||
|
||||
|
||||
STATE_CHANGE_TIME = 0.25 # seconds
|
||||
|
||||
|
||||
@callback
|
||||
def _transitions_config_parser(transitions):
|
||||
"""Parse transitions config into initialized objects."""
|
||||
|
@ -759,6 +763,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
|
|||
await self.async_set_default()
|
||||
|
||||
# Some devices (mainly nightlights) will not send back the on state so we need to force a refresh
|
||||
await asyncio.sleep(STATE_CHANGE_TIME)
|
||||
if not self.is_on:
|
||||
await self.device.async_update(True)
|
||||
|
||||
|
@ -778,6 +783,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity):
|
|||
|
||||
await self._async_turn_off(duration)
|
||||
# Some devices will not send back the off state so we need to force a refresh
|
||||
await asyncio.sleep(STATE_CHANGE_TIME)
|
||||
if self.is_on:
|
||||
await self.device.async_update(True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue