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

Using paho-mqtt 2.1 yields DeprecationWarning: Callback API version 1 is deprecated, update to latest version #528

Closed
tstabrawa opened this issue Feb 15, 2024 · 2 comments
Assignees

Comments

@tstabrawa
Copy link
Contributor

Describe the bug
While working on improvements to Insteon-MQTT, I noticed that if the latest paho-mqtt version (2.0) is used, I get the following error:

TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version'

According to this document, paho-mqtt changed several parts of its API. The old API from paho-mqtt is still available by passing callback_api_version=CallbackAPIVersion.VERSION1, though the V1 API is marked deprecated.

To Reproduce
Steps to reproduce the behavior:

  1. Set up a development environment as described here.
  2. Run pytest tests/test_Integration.py or insteon-mqtt ~/config.yaml start

Expected behavior
Test should pass / insteon-mqtt should start without throwing TypeError exception

Log Output
Please change your logging level to 10 by editing Logging.level in your config.yaml file.

# Put your relevant logging output below this line
Exception ignored in: <function Client.__del__ at 0x7fb4374c8540>
Traceback (most recent call last):
  File "/home/ironman/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 874, in __del__
    self._reset_sockets()
  File "/home/ironman/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "/home/ironman/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
           ^^^^^^^^^^
AttributeError: 'Client' object has no attribute '_sock'
Traceback (most recent call last):
  File "/home/ironman/venv/bin/insteon-mqtt", line 5, in <module>
    status = insteon_mqtt.cmd_line.main()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ironman/venv/lib/python3.11/site-packages/insteon_mqtt/cmd_line/main.py", line 587, in main
    return args.func(args, cfg)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ironman/venv/lib/python3.11/site-packages/insteon_mqtt/cmd_line/start.py", line 34, in start
    mqtt_link = network.Mqtt()
                ^^^^^^^^^^^^^^
  File "/home/ironman/venv/lib/python3.11/site-packages/insteon_mqtt/network/Mqtt.py", line 101, in __init__
    self.setup_client()
  File "/home/ironman/venv/lib/python3.11/site-packages/insteon_mqtt/network/Mqtt.py", line 111, in setup_client
    self.client = paho.Client(**client_args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version'

Your Configuration
What are the relevant entries in your config.yaml? Please include the device definition of the device affected.

N/A

Hardware Details

  • What OS is Insteon-MQTT runnning on?

Debian Bookworm

# Please paste the output of get-model for the modem below this line
NETWORK_BRIDGES (0x03): '2448A7' (0x20) 'USB Adapter'
# Please paste the output of get-model for the affected device below this line
N/A

Additional context
Add any other context about the problem here.

@tstabrawa tstabrawa mentioned this issue Feb 15, 2024
5 tasks
@tstabrawa
Copy link
Contributor Author

As of Paho version 2.1.0, the missing 1 required positional argument: 'callback_api_version' error is now replaced with a DeprecationWarning: Callback API version 1 is deprecated, update to latest version warning, due to changes in PR eclipse-paho/paho.mqtt.python#831.

There may still be some value in updating to the version 2 API, though, even if only to resolve the DeprecationWarning: Callback API version 1 is deprecated, update to latest version warning that shows when running against Paho >= 2.1.0.

Updating title to reflect new symptoms with current Paho code.

@tstabrawa tstabrawa changed the title Using paho-mqtt 2.0 yields TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version' Using paho-mqtt 2.1 yields DeprecationWarning: Callback API version 1 is deprecated, update to latest version Nov 10, 2024
@krkeegan
Copy link
Collaborator

Yup, this is something we need to fix.

It is relatively easy, and I think I locally made the changes on my machine, so I should be able to push a PR for this.

@krkeegan krkeegan self-assigned this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants