mtdcr / pysml

Python library for EDL21 smart meters using Smart Message Language (SML)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility issue with Python 3.10

DavidMStraub opened this issue · comments

Hi,

thanks for this great library!

There is a small issue when using Python 3.10, use of a deprecated function argument makes the code stop working. This was noticed because it breaks a smart meter integration in Home Assistant that relies on pysml. Would be great if you can fix it!

Relevant traceback:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/edl21/sensor.py", line 264, in async_setup_platform
    await hass.data[DOMAIN].connect()
  File "/usr/src/homeassistant/homeassistant/components/edl21/sensor.py", line 291, in connect
    await self._proto.connect(self._hass.loop)
  File "/usr/local/lib/python3.10/site-packages/sml/asyncio.py", line 132, in connect
    self._lock = asyncio.Lock(loop=loop)
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 78, in __init__
    super().__init__(loop=loop)
  File "/usr/local/lib/python3.10/asyncio/mixins.py", line 17, in __init__
    raise TypeError(
TypeError: As of 3.10, the *loop* parameter was removed from Lock() since it is no longer necessary

@mtdcr I had forgotten you authored the edl21 integration yourself 🙂
Submitted a PR that should fix the issue.