From 94b7168b1eb4f6304c85305d899790a3162a5dec Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 23 Aug 2024 09:24:46 -0500 Subject: [PATCH] home-assistant: Add restart MQTTMarionette script There's obviously a bug or something in `mqttmarionette` because it occasionally gets "stuck" in a state where it is running but does not reconnect to the MQTT broker. In such situations, it has to be restarted (and even then it doesn't shut down correctly but has to be killed with SIGKILL, usually). I have been doing this manually, but with this shell script and a corresponding "shell command" integration in Home Assistant, it can be done automatically. This is similar to how Home Assistant restarts Mopidy on the living room stereo when it gets into the same kind of state. --- home-assistant/.gitignore | 1 + home-assistant/kustomization.yaml | 2 ++ home-assistant/restart-kitchen-mqttmarionette.sh | 1 + home-assistant/shell-command.yaml | 3 +++ home-assistant/ssh_known_hosts | 2 ++ 5 files changed, 9 insertions(+) create mode 100644 home-assistant/restart-kitchen-mqttmarionette.sh create mode 100644 home-assistant/ssh_known_hosts diff --git a/home-assistant/.gitignore b/home-assistant/.gitignore index d7c660a..884a3db 100644 --- a/home-assistant/.gitignore +++ b/home-assistant/.gitignore @@ -1 +1,2 @@ mosquitto.passwd +secrets.yaml.in diff --git a/home-assistant/kustomization.yaml b/home-assistant/kustomization.yaml index 3528244..1669ebf 100644 --- a/home-assistant/kustomization.yaml +++ b/home-assistant/kustomization.yaml @@ -28,7 +28,9 @@ configMapGenerator: - event-snapshot.sh - groups.yaml - restart-diddy-mopidy.sh + - restart-kitchen-mqttmarionette.sh - shell-command.yaml + - ssh_known_hosts - rest-command.yaml options: disableNameSuffixHash: true diff --git a/home-assistant/restart-kitchen-mqttmarionette.sh b/home-assistant/restart-kitchen-mqttmarionette.sh new file mode 100644 index 0000000..8abdaa1 --- /dev/null +++ b/home-assistant/restart-kitchen-mqttmarionette.sh @@ -0,0 +1 @@ +ssh -i /run/secrets/home-assistant/sshkey.pem -oUserKnownHostsFile=/run/config/ssh_known_hosts -oBatchMode=yes kitchen@kitchen.pyrocufflink.red restart-mqttmarionette diff --git a/home-assistant/shell-command.yaml b/home-assistant/shell-command.yaml index 84c3af8..3d5ffbb 100644 --- a/home-assistant/shell-command.yaml +++ b/home-assistant/shell-command.yaml @@ -3,3 +3,6 @@ event_snapshot: >- restart_diddy_mopidy: >- sh /run/config/restart-diddy-mopidy.sh + +restart_kitchen_mqttmarionette: >- + sh /run/config/restart-kitchen-mqttmarionette.sh diff --git a/home-assistant/ssh_known_hosts b/home-assistant/ssh_known_hosts new file mode 100644 index 0000000..9eaa503 --- /dev/null +++ b/home-assistant/ssh_known_hosts @@ -0,0 +1,2 @@ +diddy.pyrocufflink.red ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILx6gRqlVnvdqTIJTH16NBLJ4ORfTsBaUIEpt5ZMkkNW +kitchen.pyrocufflink.red ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBLzMLOlFXPiovBwYLmXCVV8Md/xR36zwPj6egT9V3O7