Skip to content

Commit 91c7e9c

Browse files
authored
Merge pull request #1328 from Bastian-Krause/bst/paho-mqtt-2.0.0
driver/resource: mqtt: use callback API v2, bump paho-mqtt>=2.0.0
2 parents 00f466c + e3fc002 commit 91c7e9c

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

labgrid/driver/mqtt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TasmotaPowerDriver(Driver, PowerProtocol):
2727
def __attrs_post_init__(self):
2828
super().__attrs_post_init__()
2929
import paho.mqtt.client as mqtt
30-
self._client = mqtt.Client()
30+
self._client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
3131

3232
def on_activate(self):
3333
self._client.on_message = self._on_message
@@ -45,7 +45,7 @@ def _on_message(self, client, userdata, msg):
4545
status = False
4646
self._status = status
4747

48-
def _on_connect(self, client, userdata, flags, rc):
48+
def _on_connect(self, client, userdata, flags, reason_code, properties):
4949
client.subscribe(self.power.status_topic)
5050

5151
def _publish(self, topic, payload):

labgrid/resource/mqtt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MQTTManager(ResourceManager):
1717

1818
def _create_mqtt_connection(self, host):
1919
import paho.mqtt.client as mqtt
20-
client = mqtt.Client()
20+
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
2121
client.connect(host)
2222
client.on_message = self._on_message
2323
client.loop_start()

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ graph = ["graphviz>=0.17.0"]
6060
kasa = ["python-kasa>=0.4.0"]
6161
modbus = ["pyModbusTCP>=0.2.0"]
6262
modbusrtu = ["minimalmodbus>=1.0.2"]
63-
mqtt = ["paho-mqtt>=1.5.1"]
63+
mqtt = ["paho-mqtt>=2.0.0"]
6464
onewire = ["onewire>=0.2"]
6565
pyvisa = [
6666
"pyvisa>=1.11.3",
@@ -101,7 +101,7 @@ dev = [
101101
"minimalmodbus>=1.0.2",
102102

103103
# labgrid[mqtt]
104-
"paho-mqtt>=1.5.1",
104+
"paho-mqtt>=2.0.0",
105105

106106
# labgrid[onewire]
107107
"onewire>=0.2",

0 commit comments

Comments
 (0)