vazquezjm
(Jose Vazquez)
April 16, 2021, 2:49pm
1
Hi.
My HA Docker instance is running on Debian 10. I want to shut it down based on automation.
Right now, I’m calling hassio.host_shutdown
service which only restarts the host. Any hidden configuration (probably on the host) that I need to be aware of?
as long you can remotely access your Debian host via SSH then you can easily shutdown the host.
CLI command is running root and called shutdown now
vazquezjm
(Jose Vazquez)
April 17, 2021, 12:46pm
4
How can I call a shell command from HA?
Tried these entries in configuration.yaml
but didn’t work when called as Services
shell_command:
shutdown_zeus1: "systemctl poweroff"
shutdown_zeus2: "sudo poweroff"
thi_baut
(thi_baut)
April 17, 2021, 2:18pm
5
Create a user that will only be allowed to conduct specific commands (update sudoers file) and generate SSH key pairs
Create a shell command:
shutdown: “ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no hassuser@localhost ‘sudo shutdown -h now’”
Then a script to call it
'server_shutdown':
alias: Shutdown Server
sequence:
service: shell_command.shutdown
vazquezjm
(Jose Vazquez)
April 18, 2021, 11:26am
6
thi_baut:
Create a shell command:
shutdown: “ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no hassuser@localhost ‘sudo shutdown -h now’”
Created a shell script file (is that what you call ‘shell command’?) in the user directory named shutdownserver.sh
like so:
#! /bin/sh
ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no jose@localhost 'sudo shutdown -P'
(User jose
is a sudoer)
Created the script editing scripts.yaml
(UI doesn’t seem to work)
'server_shutdown':
alias: Shutdown Server
sequence:
service: shell_command.shutdownserver
Script is not listed in Configuration > Scripts
thi_baut
(thi_baut)
April 18, 2021, 1:15pm
7
A shell command is a specific type of integration in HA: Shell Command - Home Assistant you can place it in your configuration.yaml file (or any file included in your config. file)
The script wasn’t listed probably because HA couldn’t find the shell command