core: Yeelight integration lose constrol of light, timeout errors
The problem
Hello,
i often get error in my HA with Yeelight lights. These lights are connected to power switches. I get errors after HA is started and then i turn on Yeelight light, so it connects to WiFi. I sometimes can control the light (with slight delay) but attributes in HA are not updated and i have timeout errors in log. Sometimes i lose control of the light. When i reload integration or restart HA everything starts to work.
I’ve reported ealier similar issues with Yeelight integration
What version of Home Assistant Core has the issue?
2021.11.5
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Yeelight
Link to integration documentation on our website
https://www.home-assistant.io/integrations/yeelight/
Example YAML snippet
No response
Anything in the logs that might be useful for us?
2021-12-03 01:14:49 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_off (c:71d1250f4cbb292c07bf18ecf87e2f45): entity_id=['light.yeelight_c2_7c49ebb91d04'], params=>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 250, in _async_wrap
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 830, in _async_turn_off
await self._bulb.async_turn_off(duration=duration, light_type=self.light_type)
File "/usr/local/lib/python3.9/site-packages/yeelight/aio.py", line 36, in wrapper
cmd = await self.async_send_command(
File "/usr/local/lib/python3.9/site-packages/yeelight/aio.py", line 72, in async_send_command
response = await asyncio.wait_for(future, TIMEOUT)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1511, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 505, in async_handle_light_off_service
await light.async_turn_off(**filter_turn_off_params(light, params))
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 841, in async_turn_off
await self._async_turn_off(duration)
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 257, in _async_wrap
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Timed out when calling _async_turn_off for bulb yeelight_c2_7c49ebb91d04 at 192.168.1.149: <class 'asyncio.exceptions.TimeoutError'>
2021-12-03 01:16:45 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_on (c:adapt_lgt_5709_interval_138): entity_id=['light.yeelight_c2_7c49ebb91d04'], params=transition=8.0, brightness=38, color_temp=555>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 250, in _async_wrap
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 693, in async_set_colortemp
await self._bulb.async_set_color_temp(
File "/usr/local/lib/python3.9/site-packages/yeelight/aio.py", line 36, in wrapper
cmd = await self.async_send_command(
File "/usr/local/lib/python3.9/site-packages/yeelight/aio.py", line 72, in async_send_command
response = await asyncio.wait_for(future, TIMEOUT)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1511, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 496, in async_handle_light_on_service
await light.async_turn_on(**filter_turn_on_params(light, params))
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 791, in async_turn_on
await self.async_set_colortemp(colortemp, duration)
File "/usr/src/homeassistant/homeassistant/components/yeelight/light.py", line 257, in _async_wrap
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Timed out when calling async_set_colortemp for bulb yeelight_c2_7c49ebb91d04 at 192.168.1.149: <class 'asyncio.exceptions.TimeoutError'>
### Additional information
_No response_
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (11 by maintainers)
What I found when I was playing with this a bit, is that the same issue happens, when you directly use the
python-yeelight. I was able to get some improvements with code suggested in the PR https://gitlab.com/stavros/python-yeelight/-/merge_requests/61/diffs but nothing worth to share yet.EDIT: Here is the code which works for me. however I failed so far with asyncio 🤷♂️ https://gitlab.com/leukanos/python-yeelight/-/commit/64a2a2ef1cf2ccbda9feee4792b99e4b8cf7dffc