-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for paho-mqtt >= 2.0.0 via legacy callback API. #2916
Conversation
This is all that's required to make these scripts work properly on paho-mqtt 2.0.0, but it doesn't use the new callback API. Per the documentation, VERSION1 callbacks are deprecated but will be supported until paho-mqtt 3.
I guess we could even do without the conditional? There is a disscussion in #2840 and a change as part of #2841. Can you test if that is true? I.e. will something like these still work with paho version 1?
|
The conditional is necessary, mqtt.CallbackAPIVersion does not exist prior to paho v2.
vs
|
wow, this was merged super fast, with no opportunity for commenting. Note that paho 2.0.1 has just been released which makes compat of some things a lot better. I'm not sure it affects this issue, or just other parts. The essence is a move to keyword args so that calls with only keyword and no positional args can work in both 1.6.1 and 2.0.1. |
Sorry, it looked like the previous discussion was concluded. PRs to further improve this very welcome – or better even someone to take over the review and approvable of HA script changes, I'm not using this script and can't do QA. |
It might well have concluded, and it's quite possible that the change in 2.0.1 is not relevant. The entire paho-mqtt API break is very unfortunate. (I haven't had to the time to really pay attention and am starting to think about updating pkgsrc to paho-mqtt 2.0.1, but there is rtl_433, weewx, and some of my own scripts.) |
Unfortunately, paho.mqtt.python 2.0.0 has been out for almost 3 months and the hasattr() method seems to be the only way to support that installed base until 2.1.0 percolates out into the wild. (It looks like 2.1.0 was just released on Apr 29, and it isn't in Debian unstable yet or even properly updated on the Eclipse website for paho.) I don't think paho.mqtt.python 2.0.0 is in any distro's stable release, though, so maybe it will make sense to revert this change in a few months. It's a shame they didn't manage to avoid the breaking change in the first place, but at least unmaintained code/examples will start working again soon. |
This is all that's required to make these scripts work properly on paho-mqtt 2.0.0, but it doesn't use the new callback API. Per the documentation, VERSION1 callbacks are deprecated but will be supported until paho-mqtt 3.