From 1c9d897f89e9c9481d498055a52b5884ef9f6eba Mon Sep 17 00:00:00 2001 From: saveriol Date: Mon, 16 Sep 2024 14:35:32 +0200 Subject: [PATCH] Revert host to name in mqtt topic --- hc2mqtt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hc2mqtt.py b/hc2mqtt.py index 8d4f1d2..669245c 100755 --- a/hc2mqtt.py +++ b/hc2mqtt.py @@ -57,6 +57,7 @@ def hc2mqtt( client.publish(f"{mqtt_prefix}LWT", payload="online", qos=0, retain=True) # Re-subscribe to all device topics on reconnection for device in devices: + mqtt_topic = f"{mqtt_prefix}{device['name']}" mqtt_set_topic = f"{mqtt_prefix}{device['name']}/set" print(now(), device["name"], f"set topic: {mqtt_set_topic}") client.subscribe(mqtt_set_topic) @@ -151,7 +152,7 @@ def hc2mqtt( client.connect(host=mqtt_host, port=mqtt_port, keepalive=70) for device in devices: - mqtt_topic = mqtt_prefix + device["host"] + mqtt_topic = mqtt_prefix + device["name"] thread = Thread( target=client_connect, args=(client, device, mqtt_topic, domain_suffix, debug) )