syssi / xiaomi_raw

Custom component for Home Assistant to faciliate the reverse engeneering of Xiaomi MiIO devices
Apache License 2.0
107 stars 21 forks source link

Throws an exception after calling service due to usage of removed loop parameter in asyncio #25

Closed mo5h closed 1 year ago

mo5h commented 1 year ago

Steps to reproduce: Use the latest home assistant docker image: ghcr.io/home-assistant/generic-x86-64-homeassistant:2022.12.0 install xiaomi_raw as a custom component Setup a smart switch in it Toggle the smart switch

Expected: no exception thrown

Actual: Exception is thrown with the below stack trace


Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1745, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1782, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/xiaomi_miio_raw/sensor.py", line 136, in async_service_handler
    yield from asyncio.wait(update_tasks, loop=hass.loop)
TypeError: wait() got an unexpected keyword argument 'loop'```

This appears to be because the version of python in the pip env of the latest docker image does not allow the loop parameter to be passed to the asyncio.wait function
See: https://docs.python.org/3/library/asyncio-task.html "Changed in version 3.10: Removed the loop parameter."
mo5h commented 1 year ago

sounds like it can just be deleted, apparently it's now redundant https://stackoverflow.com/questions/60312374/what-are-all-these-deprecated-loop-parameters-in-asyncio

syssi commented 1 year ago

I will push a fix as soon as possible.

mo5h commented 1 year ago

Related PR from the Home assistant core repo for reference: https://github.com/home-assistant/core/pull/23984

syssi commented 1 year ago

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

mo5h commented 1 year ago

Gave it a whirl just now, seems to be working, thanks @syssi !