embyt / enocean-mqtt

Receives messages from an enOcean serial interface (USB) and provides selected messages to an MQTT broker.
GNU General Public License v3.0
42 stars 21 forks source link

Missing one argument in `Communicator._on_disconnect()` #47

Closed olivierkeke closed 5 months ago

olivierkeke commented 5 months ago

Hi,

I receive the following error

Exception in thread paho-mqtt-client-enocean:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 4517, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 2291, in loop_forever
    rc = self._loop(timeout)
         ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1680, in _loop
    rc = self.loop_read()
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 2096, in loop_read
    return self._loop_rc_handle(rc)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3042, in _loop_rc_handle
    self._do_on_disconnect(packet_from_broker=False, v1_rc=rc)
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 4378, in _do_on_disconnect
    on_disconnect(
TypeError: Communicator._on_disconnect() takes 5 positional arguments but 6 were given

It seems that paho-mqtt v.2 requires another argument (Maybe the _flags argument? ) for the Communicator._on_disconnect() callback :

https://github.com/embyt/enocean-mqtt/blob/460526941dc86fcb7d5877621c284433dda879e5/enoceanmqtt/communicator.py#L83

https://github.com/eclipse/paho.mqtt.python/blob/613520775c5706f72b916a99a8931983633fe489/src/paho/mqtt/client.py#L2728