Skip to content

Commit a654730

Browse files
committed
update callbacks
1 parent 6d98de9 commit a654730

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pywis_pubsub/mqtt.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def __init__(self, broker: str, options: dict = {}) -> None:
6363

6464
msg = f'Connecting to broker {self.broker_safe_url} with id {self.client_id}' # noqa
6565
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,
6768
userdata=self.userdata,
6869
transport=transport)
6970

@@ -141,15 +142,16 @@ def sub(self, topics: list, qos: int = 1) -> None:
141142
:returns: `None`
142143
"""
143144

144-
def on_connect(client, userdata, flags, rc):
145+
def on_connect(client, userdata, flags, reason_code, properties):
145146
LOGGER.debug(f'Connected to broker {self.broker_safe_url}')
146147
LOGGER.debug(f'Subscribing to topics {topics}')
147148
for topic in topics:
148149
client.subscribe(topic, qos=qos)
149150
LOGGER.debug(f'Subscribed to topic {topic}, qos {qos}')
150151

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)
153155

154156
LOGGER.debug(f'Subscribing to broker {self.broker_safe_url}, topic(s) {topics}') # noqa
155157
self.conn.on_connect = on_connect

0 commit comments

Comments
 (0)