diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index 30861fa0001..3f5bb29bab7 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -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)