Home Assistant 2022.10.5 Supervisor 2022.10.2
Operating System 9.3 Frontend 20221010.0 - latest
running haos_generic-aarch64-9.3.qcow2 virtual machine under ubuntu-aarch64 (Cheap TV box). Host mqtt.
I am concerned regarding the data corruption danger of shutting down my haos virtual machine and want to do it automatically / cleanly as part of ubuntu host shutdown service, especially if using a SD card. My research indicates I can use an mqtt message.
Here is the command (from virtual machine host - ubuntu) that is ignored:
I use docker to run Home Assistant, and have a similair case. In a certain scenario I want to shutdown the host server, initiated frome Home Assistant.
What I do is run a shell command from an automation, writing some specific text in a file. On the host server I have a script that starts at boot, and runs in a loop, that monitors that file. When the text is found, shutdown command is given.
There is no âbuilt-in methodâ and the corrected link you posted misled you into believing there is one.
Just use aceindyâs automation. Itâs concise and does exactly what you want. Using an MQTT Trigger, you can define whatever topic and payload you want.
Go to Developer Tools > Services and enter âhassioâ. It will list the available service calls:
#1 HA has no builtin method to reboot or execute any services from MQTT messages. Need to define MQTT topic, message(s) and create automation: #2 Absolutely do not use -r (retain) when sending MQTT shutdown, reboot messages. They will be received and acted upon at HA start, leading to reboot loop.
I implemented the re-boot command because, occasionally communication to host USB devices (zigbee, zwave HUSZB-1) craps out for some reason and a HA reboot is required. Intend to detect this state and reboot using another automation.
NOTE: It takes a long time for SHUTDOWN, REBOOT to happen (not including HA restart time). Hints to reduce this time appreciated.
If aceindyâs suggestion solved your problem then itâs customary to tag aceindyâs post with the Solution tag (not your own which merely implements aceindyâs example). For more information about the Solution tag, refer to guideline 21 in the FAQ.
NOTE
Thereâs no need to create separate automations for each command (nor is there a need to capitalize portions of an MQTT topic) and can be done with a single automation.