From dedc6595ca7ce0c93576934760197b0e22dae95f Mon Sep 17 00:00:00 2001 From: Hristo Date: Mon, 5 Feb 2024 21:01:40 +0200 Subject: [PATCH] add payload_press configuration to make mqtt message differ --- src/rpi-cpu2mqtt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpi-cpu2mqtt.py b/src/rpi-cpu2mqtt.py index 64a6c27..737425d 100644 --- a/src/rpi-cpu2mqtt.py +++ b/src/rpi-cpu2mqtt.py @@ -320,6 +320,7 @@ def config_json(what_config): data["icon"] = "mdi:restart" data["name"] = "System Restart" data["command_topic"] = "homeassistant/update/" + hostname + "/command" + data["payload_press"] = "restart" else: return "" # Return our built discovery config @@ -587,7 +588,7 @@ def on_message(client, userdata, msg): thread1.join() # Wait for thread1 to finish thread2.join() # Wait for thread2 to finish sys.exit(0) # Exit the script - elif msg.payload.decode() == "PRESS": + elif msg.payload.decode() == "restart": print("Restarting the application...") # restart the system print("Restarting the system...")