Skip to content

Commit

Permalink
feat: bump paho api version to V2
Browse files Browse the repository at this point in the history
* updated affected callbacks according to paho migration guide
  • Loading branch information
hyperspacex2 committed Oct 30, 2024
1 parent 08924ee commit a2e0dff
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pytest_mqtt/capmqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def __init__(self, on_message_callback: t.Optional[t.Callable] = None, host: str
self.client = mqtt.Client()
else:
# paho-mqtt 2.x
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self.client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
self.client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
self.on_message_callback = on_message_callback
self.host = host
self.port = int(port)
Expand Down Expand Up @@ -68,10 +66,10 @@ def stop(self):
def on_socket_open(self, client, userdata, sock):
logger.debug("[PYTEST] Opened socket to MQTT broker")

def on_connect(self, client, userdata, flags, rc):
def on_connect(self, client, userdata, flags, reason_code, properties):
logger.debug("[PYTEST] Connected to MQTT broker")

def on_subscribe(self, client, userdata, mid, granted_qos, properties=None):
def on_subscribe(self, client, userdata, mid, reason_codes, properties):
logger.debug("[PYTEST] Subscribed to MQTT topic(s)")

def on_message(self, client, userdata, msg):
Expand Down

0 comments on commit a2e0dff

Please sign in to comment.