Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to set up: Unsupported callback API version #531

Open
jordanwmcdonald opened this issue Feb 27, 2025 · 18 comments
Open

Failed to set up: Unsupported callback API version #531

jordanwmcdonald opened this issue Feb 27, 2025 · 18 comments
Labels
bug Something isn't working fixed Upcoming fix/feature already on dev

Comments

@jordanwmcdonald
Copy link

Version of the custom_component

5.4.1

Configuration

Core: 2025.3.0b0
Supervisor: 2025.02.4
Operating System: 14.2
Frontend: 20250226.0

Describe the bug

Add-on stopped working in the last 24 hours with the following error. Issue persists after reboots and clean installs:

Failed to set up: Unsupported callback API version: version 2.0 added a callback_api_version, see docs/migrations.rst for details.

Debug log


2025-02-26 18:00:15.565 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry [email protected] for meross_lan: Unsupported callback API version: version 2.0 added a callback_api_version, see docs/migrations.rst for details
Traceback (most recent call last):
  File "/config/custom_components/meross_lan/__init__.py", line 615, in async_setup_entry
    await profile.async_init()
  File "/config/custom_components/meross_lan/meross_profile.py", line 962, in async_init
    mqttconnection = MerossMQTTConnection(self, broker)
  File "/config/custom_components/meross_lan/meross_profile.py", line 768, in __init__
    MerossMQTTAppClient.__init__(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self,
        ^^^^^
    ...<4 lines>...
        sslcontext=get_default_ssl_context(),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/meross_lan/merossclient/mqttclient.py", line 345, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        f"app:{app_id}", [(self.topic_push, 1), (self.topic_command, 1)], loop=loop
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/meross_lan/merossclient/mqttclient.py", line 79, in __init__
    super().__init__(client_id, protocol=mqtt.MQTTv311)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/paho/mqtt/client.py", line 772, in __init__
    raise ValueError(
        "Unsupported callback API version: version 2.0 added a callback_api_version, see docs/migrations.rst for details"
    )
ValueError: Unsupported callback API version: version 2.0 added a callback_api_version, see docs/migrations.rst for details

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 753, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/meross_lan/__init__.py", line 627, in async_setup_entry
    raise ConfigEntryError from error
@pleasantone
Copy link

can confirm, also seeing with freshly installed 2025.3.0b0

@pleasantone
Copy link

Initial guess is that the version bump of paho-mqtt to 2.1.0 affected deprecated APIs and merross_lan needs to be brought up to use the current API.

The docs on what needs to be done are at: https://github.com/eclipse-paho/paho.mqtt.python/blob/master/docs/migrations.rst

@pleasantone
Copy link

pleasantone commented Feb 27, 2025

I'm not in a position to write and test a pull request right now, but the fix is in mqttclient.py

in _MerossMQTTClient:

super().__init__(client_id, ...)

becomes

from paho.mqtt import __version__ as paho_mqtt_version

if paho_mqtt_version major version is greater than 1:
    super().__init__(CallbackAPIVersion.VERSION1, client_id, ...)
else:
    super().__init__(client_id, ...)

or better yet consider something like:

try:
    import CallbackAPIVersion from paho.mqtt.enums
    super().__init__(CallbackAPIVersion.VERSION1, client_id, ...)
except (whateversymbolnotfounderror or importerror is named):
    super().__init__(client_id, ...)

Please note this is the minimum change to make it work with both newer and older code, but API version 1 is deprecated.

Better yet, kill off a future problem before it happens and read migrations.rst and clean up our API usage to ensure we can raise this to v2.

@Seagull1901
Copy link

Same issue here, struggling to get the code working @pleasantone that you posted

@nobbilie
Copy link

The same here, I hope for a quick fix.

@krahabb
Copy link
Owner

krahabb commented Feb 28, 2025

Hello, thank you all for your quick raising of this issue...I'm pretty off in latest months so I'm not very up to date with code and this issue is much needed to quickly fix this!

I'm going to fix this asap..likely before 2025.3 hits the public!

EDIT:
The fix could be not as easy as patching the initialization since there might also be some conflicts on new properties added to the base paho mqtt client

@krahabb krahabb added bug Something isn't working todo This item needs processing labels Feb 28, 2025
@krahabb krahabb mentioned this issue Mar 1, 2025
@krahabb krahabb added fixed Upcoming fix/feature already on dev and removed todo This item needs processing labels Mar 1, 2025
@pleasantone
Copy link

Nice code @krahabb , thank you!

@massida06
Copy link

hello everyone, I recently updated the Meross Lan integration and since then it no longer works for the same reason. I tried to modify the code in /meross_lan/merossclient/mqttclient.py but still I did not solve anything. Maybe because I wrote the correction wrong? I ask you for help

@krahabb
Copy link
Owner

krahabb commented Mar 8, 2025

I'd ask for comments from people who where experiencing the issue and see if they still have problems with latest meross_lan v5.4.2

I've still haven't installed HA core 2025.3 in my production env but tests in develop were succesful iusing meross_lan v5.4.2 in both HA core 2025.2 and now 2025.3

@pleasantone
Copy link

pleasantone commented Mar 8, 2025 via email

@massida06
Copy link

Funziona alla grande per me sia su 2025.2 che su 2025.3
...

ah ok. could you please tell me the steps to solve it?

@pleasantone
Copy link

pleasantone commented Mar 8, 2025 via email

@krahabb
Copy link
Owner

krahabb commented Mar 8, 2025

Maybe download it again in case something went wrong with the downloading.
v5.4.2 is correctly patched to work for the new HA core (2025.3) and the previous too without any modification.

@ottah2023
Copy link

@krahabb I forced a download of Meross LAN v5.4.2 via HACS, and once installed the issue appears to be fixed.

Core: 2025.3.1
Frontend: 20250306.0

@Phorteau
Copy link

Phorteau commented Mar 9, 2025

@krahabb I forced a download of Meross LAN v5.4.2 via HACS, and once installed the issue appears to be fixed.

Core: 2025.3.1 Frontend: 20250306.0

I can't even see Meross LAN under HACS anymore. I'm on Meross LAN v5.4.1 and can't upgrade to v.5.4.2...

@marcellr84
Copy link

Download Version 5.4.2 -> restart Home Assistant = Problem fixed

Core
2025.3.1
Supervisor
2025.03.2
Operating System
14.2
Frontend
20250306.0

@robinbon
Copy link

robinbon commented Mar 9, 2025

sorry stupid question, i have this problem.

how do you update meross lan ?
Do I have to delete existing one and then reinstall ?

thanks

@robinbon
Copy link

robinbon commented Mar 9, 2025

update,
my HA just prompted for an updated to HACS just now.
then prompted for Meross Lan update.

did both and its back in action.

thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Upcoming fix/feature already on dev
Projects
None yet
Development

No branches or pull requests

10 participants