add payload_press configuration to make mqtt message differ

This commit is contained in:
Hristo
2024-02-05 21:01:40 +02:00
parent f75c0a7f1d
commit dedc6595ca

View File

@@ -320,6 +320,7 @@ def config_json(what_config):
data["icon"] = "mdi:restart" data["icon"] = "mdi:restart"
data["name"] = "System Restart" data["name"] = "System Restart"
data["command_topic"] = "homeassistant/update/" + hostname + "/command" data["command_topic"] = "homeassistant/update/" + hostname + "/command"
data["payload_press"] = "restart"
else: else:
return "" return ""
# Return our built discovery config # Return our built discovery config
@@ -587,7 +588,7 @@ def on_message(client, userdata, msg):
thread1.join() # Wait for thread1 to finish thread1.join() # Wait for thread1 to finish
thread2.join() # Wait for thread2 to finish thread2.join() # Wait for thread2 to finish
sys.exit(0) # Exit the script sys.exit(0) # Exit the script
elif msg.payload.decode() == "PRESS": elif msg.payload.decode() == "restart":
print("Restarting the application...") print("Restarting the application...")
# restart the system # restart the system
print("Restarting the system...") print("Restarting the system...")