Shutdown host OS (Debian 10)

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

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"

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

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 :thinking:

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