@@ -63,7 +63,8 @@ def __init__(self, broker: str, options: dict = {}) -> None:
63
63
64
64
msg = f'Connecting to broker { self .broker_safe_url } with id { self .client_id } ' # noqa
65
65
LOGGER .debug (msg )
66
- self .conn = mqtt_client .Client (self .client_id ,
66
+ self .conn = mqtt_client .Client (mqtt_client .CallbackAPIVersion .VERSION2 ,
67
+ self .client_id ,
67
68
userdata = self .userdata ,
68
69
transport = transport )
69
70
@@ -141,15 +142,16 @@ def sub(self, topics: list, qos: int = 1) -> None:
141
142
:returns: `None`
142
143
"""
143
144
144
- def on_connect (client , userdata , flags , rc ):
145
+ def on_connect (client , userdata , flags , reason_code , properties ):
145
146
LOGGER .debug (f'Connected to broker { self .broker_safe_url } ' )
146
147
LOGGER .debug (f'Subscribing to topics { topics } ' )
147
148
for topic in topics :
148
149
client .subscribe (topic , qos = qos )
149
150
LOGGER .debug (f'Subscribed to topic { topic } , qos { qos } ' )
150
151
151
- def on_disconnect (client , userdata , rc ):
152
- LOGGER .debug (f'Disconnected from { self .broker_safe_url } : ({ rc } )' )
152
+ def on_disconnect (client , userdata , flags , reason_code , properties ):
153
+ msg = f'Disconnected from { self .broker_safe_url } : ({ reason_code } )'
154
+ LOGGER .debug (msg )
153
155
154
156
LOGGER .debug (f'Subscribing to broker { self .broker_safe_url } , topic(s) { topics } ' ) # noqa
155
157
self .conn .on_connect = on_connect
0 commit comments