Skip to content

Commit

Permalink
fix: Update code to be compatible with paho-mqtt>=2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjw committed Jun 28, 2024
1 parent 3f7c52a commit c35886c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/prom433
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import sys

from prom433 import get_arguments, serve, prometheus

def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
def on_connect(client: mqtt.Client, userdata, flags, reason_code, properties):
if reason_code > 0:
sys.stderr.write(f"Failed to connect to mqtt: {reason_code}")

print("Successfully connected to mqtt broker.")
client.subscribe("rtl_433/+/events")


Expand Down Expand Up @@ -55,7 +57,7 @@ def parse_mqtt_url(url: str) -> Tuple[str, int]:
def main():
args = get_arguments(sys.argv[1:])

client = mqtt.Client()
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)

client.on_connect = on_connect
client.on_message = \
Expand Down

0 comments on commit c35886c

Please sign in to comment.