I have plain home assistant on an intel nuc (no VM, no venv, no docker, no hassio).
I start it with “.local/bin/hass”.
Is there a way to stop it on from the command line or REST url?
The reason is that when I automatically shutdown the machine, I want to stop HA before shutdown.
(without manual intervention)
You can invoke a service using the REST API. In this case you can use the homeassistant/stop
service.
Ah ok thank you. It is
curl -X POST -H "Authorization: Bearer token123" -H "Content-Type: application/json" http://localhost:8123/api/services/homeassistant/stop
2 Likes
Exactly, but where is the documentation it comes from?
The docs used to have instructions for seeing you a systemctl service for core installs. Unfortunately it seems to be gone…
EDIT: See here Autostart using systemd
So does it make sense to use
ExecStop=curl -X POST -H "Authorization: Bearer token123" -H "Content-Type: application/json" http://localhost:8123/api/services/homeassistant/stop
in the service unit?
Why would you?
If I run “systemctl stop homeassistant”, home assistant is not stopped gracefully. It is just terminated, and sometimes the recorder database is damaged.