Skip to content

Commit

Permalink
Merge pull request #1328 from Bastian-Krause/bst/paho-mqtt-2.0.0
Browse files Browse the repository at this point in the history
driver/resource: mqtt: use callback API v2, bump paho-mqtt>=2.0.0
  • Loading branch information
Emantor authored Feb 14, 2024
2 parents 00f466c + e3fc002 commit 91c7e9c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions labgrid/driver/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TasmotaPowerDriver(Driver, PowerProtocol):
def __attrs_post_init__(self):
super().__attrs_post_init__()
import paho.mqtt.client as mqtt
self._client = mqtt.Client()
self._client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)

def on_activate(self):
self._client.on_message = self._on_message
Expand All @@ -45,7 +45,7 @@ def _on_message(self, client, userdata, msg):
status = False
self._status = status

def _on_connect(self, client, userdata, flags, rc):
def _on_connect(self, client, userdata, flags, reason_code, properties):
client.subscribe(self.power.status_topic)

def _publish(self, topic, payload):
Expand Down
2 changes: 1 addition & 1 deletion labgrid/resource/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MQTTManager(ResourceManager):

def _create_mqtt_connection(self, host):
import paho.mqtt.client as mqtt
client = mqtt.Client()
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
client.connect(host)
client.on_message = self._on_message
client.loop_start()
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ graph = ["graphviz>=0.17.0"]
kasa = ["python-kasa>=0.4.0"]
modbus = ["pyModbusTCP>=0.2.0"]
modbusrtu = ["minimalmodbus>=1.0.2"]
mqtt = ["paho-mqtt>=1.5.1"]
mqtt = ["paho-mqtt>=2.0.0"]
onewire = ["onewire>=0.2"]
pyvisa = [
"pyvisa>=1.11.3",
Expand Down Expand Up @@ -101,7 +101,7 @@ dev = [
"minimalmodbus>=1.0.2",

# labgrid[mqtt]
"paho-mqtt>=1.5.1",
"paho-mqtt>=2.0.0",

# labgrid[onewire]
"onewire>=0.2",
Expand Down

0 comments on commit 91c7e9c

Please sign in to comment.