Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for paho-mqtt >= 2.0.0 via legacy callback API. #2916

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/mqtt_rtl_433_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

# log = logging.getLogger() # Single process logger
log = mp.log_to_stderr() # Multiprocessing capable logger
mqtt_client = mqtt.Client("RTL_433_Test")
if hasattr(mqtt, 'CallbackAPIVersion'): # paho >= 2.0.0
mqtt_client = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION1, client_id="RTL_433_Test")
else:
mqtt_client = mqtt.Client(client_id="RTL_433_Test")

sensor_state = dict() # Dictionary containing accumulated sensor state

Expand Down
5 changes: 4 additions & 1 deletion examples/rtl_433_mqtt_hass.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,10 @@ def bridge_event_to_hass(mqttc, topic_prefix, data):
def rtl_433_bridge():
"""Run a MQTT Home Assistant auto discovery bridge for rtl_433."""

mqttc = mqtt.Client()
if hasattr(mqtt, 'CallbackAPIVersion'): # paho >= 2.0.0
mqttc = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION1)
else:
mqttc = mqtt.Client()

if args.debug:
mqttc.enable_logger()
Expand Down
5 changes: 4 additions & 1 deletion examples/rtl_433_mqtt_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ def rtl_433_probe():
"""Run a rtl_433 UDP listener."""

## Connect to MQTT
mqttc = mqtt.Client()
if hasattr(mqtt, 'CallbackAPIVersion'): # paho >= 2.0.0
mqttc = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION1)
else:
mqttc = mqtt.Client()
mqttc.on_connect = mqtt_connect
mqttc.on_disconnect = mqtt_disconnect
if MQTT_USERNAME != None:
Expand Down