Merge branch 'mqtt_lwt' of github.com:Meatballs1/hcpy-2.0 into mqtt_lwt

This commit is contained in:
Meatballs1
2024-03-20 13:53:54 +00:00

View File

@@ -94,7 +94,6 @@ def hc2mqtt(
except Exception as e: except Exception as e:
print(now(), device_name, "ERROR", e, file=sys.stderr) print(now(), device_name, "ERROR", e, file=sys.stderr)
click.echo( click.echo(
f"Hello {devices_file=} {mqtt_host=} {mqtt_prefix=} " f"Hello {devices_file=} {mqtt_host=} {mqtt_prefix=} "
f"{mqtt_port=} {mqtt_username=} {mqtt_password=} " f"{mqtt_port=} {mqtt_username=} {mqtt_password=} "
@@ -202,7 +201,11 @@ def client_connect(client, device, mqtt_topic):
print(now(), device["name"], f"publish to {mqtt_topic} with {msg}") print(now(), device["name"], f"publish to {mqtt_topic} with {msg}")
client.publish(f"{mqtt_topic}/state", msg) client.publish(f"{mqtt_topic}/state", msg)
else: else:
print(now(), device["name"], "ERROR Unable to publish update as mqtt is not connected.") print(
now(),
device["name"],
"ERROR Unable to publish update as mqtt is not connected.",
)
except Exception as e: except Exception as e:
print(device["name"], "ERROR", e, file=sys.stderr) print(device["name"], "ERROR", e, file=sys.stderr)