Compare commits

...

4 Commits

Author SHA1 Message Date
Fabio Manganiello 19a90ee045 Merge branch 'master' into 304-new-picovoice-integration
continuous-integration/drone/push Build is passing Details
2024-04-13 20:04:32 +02:00
Fabio Manganiello 027bcea612
[Automatic] Updated components cache
continuous-integration/drone/push Build is passing Details
2024-04-08 21:05:46 +00:00
Fabio Manganiello b4d0716bc5
Added layer of compatibility with both paho.mqtt >= 2.0.0 and < 2.0.0.
See 28aa2e6b26/ChangeLog.txt (L6)
2024-04-08 23:01:54 +02:00
revil-O 584f226b62 mqtt CallbackAPIVersion fix for paho.mqtt >= 2.0.0
fix to work with paho.mqtt >= 2.0.0
2024-04-08 16:05:27 +02:00
2 changed files with 11 additions and 1 deletions

Binary file not shown.

View File

@ -37,7 +37,17 @@ class MqttClient(mqtt.Client, threading.Thread):
**kwargs,
):
self.client_id = client_id or str(Config.get('device_id'))
mqtt.Client.__init__(self, *args, client_id=self.client_id, **kwargs)
kwargs['client_id'] = self.client_id
# Breaking change in paho.mqtt >= 2.0.0: the callback API version
# parameter should be passed, see
# https://github.com/eclipse/paho.mqtt.python/blob/28aa2e6b26a86e4b29126323892fb5f43637d6d6/ChangeLog.txt#L6
cbApiVersion = getattr(mqtt, 'CallbackAPIVersion', None)
if cbApiVersion:
kwargs['callback_api_version'] = cbApiVersion.VERSION1
mqtt.Client.__init__(self, *args, **kwargs)
threading.Thread.__init__(self, name=f'MQTTClient:{self.client_id}')
self.logger = logging.getLogger(self.__class__.__name__)