Reboot other raspberry

I have home assistant installed on hassio and I would like to create a switch with which I can switch off another raspberry with the number ip 192.168.1.115. do you think it’s feasible?

You could use a smart home socket controller by Home Assistant but that is not too clean.
Do you just need to shutdown the OS or power off too?
Also, switch off or reboot? You said both.

Shutdown or reboot os

Do something using ssh? If you use it key based no passwords are needed.

I do this, but I am not using hassio, just running Home Assistant in venv. What I did was to first generate ssh key pairs and then used a command line switch to run a script which just logs into the remote raspberry and reboots it. It might be tricky to do on hassio.

Another option is to install mosquitto on the remote raspberry and then listen for an mqtt message through a python script that shuts down the machine when the right message is received.

Install mosquito?

Mosquitto is an MQTT broker, same as Home Assistant is using. It might even be installed by default on the raspberry. You can then use an MQTT switch in Home Assistant to send a shutdown message.

is an example possible to create this switch dia from the client side than from the server side?

Sorry, don’t exactly understand what you are asking. Mosquitto is bi-directional so you can send messages both ways, i.e. you can both receive and send messages from your other raspberry if you have mosquitto installed.

ssh 192.168.1.115 reboot

is not ossible because ask for password

an example to implement this procedure?

You have been given the answer - key based authentication.

I created the key, copied in the other raspberry. from the client I can access and restart the other raspberry from CLI but from home assistant I am not getting results.
This is the script and the Shell command in configuration.yaml

shell_command: 
  reboot_dietpi: ssh -l root 192.168.1.34 "sudo reboot"

script:
  reboot_dietpi:
    alias: Reboot Dietpi Script
    sequence:
    - service: shell_command.reboot_dietpi

generate a ssh key that is valid for login without any passphrase and add it to the remote $HOME_DIR/.ssh/authorized_keys file.

append the shell command with -i /path/to/the/key and copy the key to the directory that is readable for the hass system.

don’t forget to chmod 600 the key.

a bit more secure would be to define a command in the authorized_keys file.

already done. home assistant script does not work

show your script, and ls -l of the the keyfile.

debug the ssh connection with “-v” before the ssh command

shell_command: 
  reboot_dietpi: ssh -l root 192.168.1.34 "sudo reboot"

script:
  reboot_dietpi:
    alias: Reboot Dietpi Script
    sequence:
    - service: shell_command.reboot_dietpi

There is a trick to this, it has been covered in other threads. It is about ssh asking if you want to accept the certiciate of the ssh server (ie the dietpi). Make sure you run the command in a terminal at least once as the user homeassistant.

homeassistant not root??