krahabb / meross_lan

Home Assistant integration for Meross devices
MIT License
450 stars 47 forks source link

Syntax error in v5.4.1-alpha.0 #502

Closed HeikoTietze closed 1 month ago

HeikoTietze commented 1 month ago

File "/mnt/dietpi_userdata/homeassistant/custom_components/meross_lan/helpers/manager.py", line 177 def async_create_task[ ^ SyntaxError: expected '(' 2024-10-15 16:11:01.216 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration meross_lan: Unable to import component: Exception importing custom_components.meross_lan

And changing this into def async_create_task[_R](... does not help.

Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux

krahabb commented 1 month ago

Hello @HeikoTietze, Sorry for that..I guess I've introduced some python 3.12 syntax there. If I'm not wrong, removing the [_R] typing (together with any occurrencr of _R) should be compatible (it's just type hinting)..I'll promptly check/fix for the next (pre)release.

HeikoTietze commented 1 month ago

alpha.1 spams this (and returns "Unavailable" for the entities)

2024-10-15 19:41:21.845 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback EntityManager.schedule_async_callback.._callback(>, None) at /mnt/dietpi_userdata/homeassistant/custom_components/meross_lan/helpers/manager.py:165 Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/asyncio/events.py", line 80, in _run self._context.run(self._callback, self._args) File "/mnt/dietpi_userdata/homeassistant/custom_components/meross_lan/helpers/manager.py", line 167, in _callback self.async_create_task(_target(_args), "._callback") File "/mnt/dietpi_userdata/homeassistant/custom_components/meross_lan/helpers/manager.py", line 183, in async_create_task task = self.hass.async_create_task(target, f"{self.logtag}{name}", eager_start) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: HomeAssistant.async_create_task() takes from 2 to 3 positional arguments but 4 were given 2024-10-15 19:41:21.880 WARNING (MainThread) [py.warnings] :123: RuntimeWarning: coroutine 'MerossDevice._async_polling_callback' was never awaited

krahabb commented 1 month ago

Aww yeah...I don't have a testing facility in place for older HA core versions so it looks like that call in HA core is different (I'm sure the last parameter 'eager_start' was added only in recent months)

Which HA core version are you on?

HeikoTietze commented 1 month ago

Core 2023.11.3 Frontend 20231030.2 I'm running it on a RasPi 4b with DietPi OS, being bound to their update schedule. Failed to set-up HA OS, or to install some needed plugin. Don't remember what it was.

krahabb commented 1 month ago

I've tried patching specifically that api call but I cannot really thoroughly test it anymore since many things have changed so far in core api and my test suite doesn't match well with older versions... Corssfingers and hope for the best, I'm (almost) confident this specific compatibility issue has been fixed but I'm scared many other subtleties could not be verified.

HeikoTietze commented 1 month ago

This works! Thanks a lot.