Skip to content

Commit 400029c

Browse files
committed
Upgrade paho-mqtt from 1.6.1 to 2.1.0
1 parent f490e1a commit 400029c

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

inelsmqtt/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
import threading
66
import time
7-
import uuid
87
from collections import defaultdict
98
from datetime import datetime
109
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
@@ -20,7 +19,6 @@
2019
DISCOVERY_TIMEOUT_IN_SEC,
2120
FRAGMENT_DEVICE_TYPE,
2221
FRAGMENT_STATE,
23-
MQTT_CLIENT_ID,
2422
MQTT_HOST,
2523
MQTT_PASSWORD,
2624
MQTT_PORT,
@@ -68,10 +66,12 @@ def __init__(
6866
if _t not in MQTT_TRANSPORTS:
6967
raise Exception
7068

71-
if (client_id := config.get(MQTT_CLIENT_ID)) is None:
72-
client_id = mqtt.base62(uuid.uuid4().int, padding=22)
73-
74-
self.__client = mqtt.Client(client_id, protocol=self.__proto, transport=_t)
69+
self.__client = mqtt.Client(
70+
callback_api_version=mqtt.CallbackAPIVersion.VERSION2,
71+
protocol=self.__proto,
72+
transport=_t,
73+
reconnect_on_failure=True,
74+
)
7575

7676
self.__client.on_connect = self.__on_connect
7777
self.__client.on_subscribe = self.__on_subscribe
@@ -270,6 +270,7 @@ def __on_disconnect(
270270
self,
271271
client: mqtt.Client, # pylint: disable=unused-argument
272272
userdata: Any, # pylint: disable=unused-argument
273+
disconnect_flags: dict,
273274
reason_code: int,
274275
properties: Optional[Properties] = None,
275276
) -> None:
@@ -278,6 +279,7 @@ def __on_disconnect(
278279
Args:
279280
client (mqtt.Client): instance of the mqtt client
280281
userdata (Any): user's data
282+
disconnect_flags (dict): response flags sent by the broker
281283
reason_code (int): reason code for disconnection
282284
properties (Optional[Properties]): MQTT v5 properties
283285
"""
@@ -298,7 +300,7 @@ def __on_connect(
298300
self,
299301
client: mqtt.Client, # pylint: disable=unused-argument
300302
userdata: Any, # pylint: disable=unused-argument
301-
flags: dict,
303+
connect_flags: dict,
302304
reason_code: int,
303305
properties: Optional[Properties] = None, # pylint: disable=unused-argument
304306
) -> None:
@@ -307,7 +309,7 @@ def __on_connect(
307309
Args:
308310
client (mqtt.Client): instance of mqtt client
309311
userdata (Any): user data as set in Client() or user_data_set()
310-
flags (dict): response flags sent by the broker
312+
connect_flags (dict): response flags sent by the broker
311313
reason_code (int): the connection result
312314
properties (Optional[Properties]): the MQTT v5 properties returned from the broker
313315
"""
@@ -425,7 +427,7 @@ def __on_subscribe(
425427
client: mqtt.Client, # pylint: disable=unused-argument
426428
userdata: Any, # pylint: disable=unused-argument
427429
mid: int, # pylint: disable=unused-argument
428-
granted_qos: List[int], # pylint: disable=unused-argument
430+
reason_code_list: List[int], # pylint: disable=unused-argument
429431
properties: Optional[Any] = None, # pylint: disable=unused-argument
430432
) -> None:
431433
"""Callback for subscribe function."""
@@ -448,7 +450,7 @@ def __on_unsubscribe(
448450
userdata: Any,
449451
mid: int,
450452
properties: Optional[Any] = None,
451-
reasoncodes: Optional[List[int]] = None,
453+
reason_code_list: Optional[List[int]] = None,
452454
) -> None:
453455
"""Callback for when the client receives an UNSUBACK response from the broker."""
454456
topic_to_remove = None

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
paho-mqtt>=1.6.1
1+
paho-mqtt>=2.1.0
22
attrs>=21.2.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name="elkoep-mqtt",
7-
version="0.2.33.beta.20",
7+
version="0.2.33.beta.21",
88
url="https://github.com/epdevlab/elkoep-mqtt",
99
license="MIT",
1010
author="Elko EP s.r.o.",

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
paho-mqtt==1.6.1
1+
paho-mqtt==2.1.0
22
pytest==8.2.0
33
attrs>=21.2.0

0 commit comments

Comments
 (0)