syssi / xiaomi_fan

Xiaomi Mi Smart Fan integration for Home Assistant
Apache License 2.0
413 stars 117 forks source link

"Passing coroutines is forbidden, use tasks explicitly" - Python incompatibility? #216

Closed ostracizado closed 1 year ago

ostracizado commented 1 year ago

The services still work, but every time one is executed the error appears.

I've noticied some problems related with "async", in other custom components, and the new changes with Python... could it be the problem?

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/xiaomi_miio_fan/fan.py:518
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 13:20:30 (11 occurrences)
Last logged: 13:30:13

[140615723197776] Passing coroutines is forbidden, use tasks explicitly.
[140615723197776] Error handling message: Unknown error (unknown_error) ### from 192.168.2.### (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 205, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1910, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1950, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 488, in _service_handler
    await self.async_turn_on(variables=service.data, context=service.context)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 447, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 477, in _async_run
    return await self.script.async_run(script_vars, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1533, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 410, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 477, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1910, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1950, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/xiaomi_miio_fan/fan.py", line 518, in async_service_handler
    await asyncio.wait(update_tasks)
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 415, in wait
    raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.
syssi commented 1 year ago

I've pushed a fix and prepared a new release. Please give it a try!