mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-28 19:34:05 +02:00
Merge pull request #2165 from alexbelgium/codex/fix-issue-#2162-on-github
Fix BirdNET-Pi MQTT callback compatibility with paho 2.x
This commit is contained in:
@@ -113,7 +113,14 @@ def automatic_mqtt_publish(file, detection, path):
|
|||||||
log.info("Posted to MQTT: ok")
|
log.info("Posted to MQTT: ok")
|
||||||
|
|
||||||
|
|
||||||
mqttc = mqtt.Client("birdnet_mqtt", callback_api_version=4)
|
# Create MQTT client using legacy callback API when available for
|
||||||
|
# compatibility with paho-mqtt >= 2.0
|
||||||
|
callback_api = getattr(mqtt, "CallbackAPIVersion", None)
|
||||||
|
|
||||||
|
if callback_api is not None:
|
||||||
|
mqttc = mqtt.Client("birdnet_mqtt", callback_api_version=callback_api.VERSION1)
|
||||||
|
else:
|
||||||
|
mqttc = mqtt.Client("birdnet_mqtt")
|
||||||
mqttc.username_pw_set(mqtt_user, mqtt_pass)
|
mqttc.username_pw_set(mqtt_user, mqtt_pass)
|
||||||
mqttc.on_connect = on_connect
|
mqttc.on_connect = on_connect
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user