Revert host to name in mqtt topic
This commit is contained in:
@@ -57,6 +57,7 @@ def hc2mqtt(
|
|||||||
client.publish(f"{mqtt_prefix}LWT", payload="online", qos=0, retain=True)
|
client.publish(f"{mqtt_prefix}LWT", payload="online", qos=0, retain=True)
|
||||||
# Re-subscribe to all device topics on reconnection
|
# Re-subscribe to all device topics on reconnection
|
||||||
for device in devices:
|
for device in devices:
|
||||||
|
mqtt_topic = f"{mqtt_prefix}{device['name']}"
|
||||||
mqtt_set_topic = f"{mqtt_prefix}{device['name']}/set"
|
mqtt_set_topic = f"{mqtt_prefix}{device['name']}/set"
|
||||||
print(now(), device["name"], f"set topic: {mqtt_set_topic}")
|
print(now(), device["name"], f"set topic: {mqtt_set_topic}")
|
||||||
client.subscribe(mqtt_set_topic)
|
client.subscribe(mqtt_set_topic)
|
||||||
@@ -151,7 +152,7 @@ def hc2mqtt(
|
|||||||
client.connect(host=mqtt_host, port=mqtt_port, keepalive=70)
|
client.connect(host=mqtt_host, port=mqtt_port, keepalive=70)
|
||||||
|
|
||||||
for device in devices:
|
for device in devices:
|
||||||
mqtt_topic = mqtt_prefix + device["host"]
|
mqtt_topic = mqtt_prefix + device["name"]
|
||||||
thread = Thread(
|
thread = Thread(
|
||||||
target=client_connect, args=(client, device, mqtt_topic, domain_suffix, debug)
|
target=client_connect, args=(client, device, mqtt_topic, domain_suffix, debug)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user