insteon-mqtt
insteon-mqtt copied to clipboard
Using paho-mqtt 2.0 yields TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version'
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:
- Set up a development environment as described here.
- Run
pytest tests/test_Integration.py
orinsteon-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
- The model of your Modem, see https://github.com/TD22057/insteon-mqtt/blob/master/docs/mqtt.md#get-device-model-information
# Please paste the output of get-model for the modem below this line
NETWORK_BRIDGES (0x03): '2448A7' (0x20) 'USB Adapter'
- The model of the affected Device, see https://github.com/TD22057/insteon-mqtt/blob/master/docs/mqtt.md#get-device-model-information
# 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.