Control a raspberry pi via Home Assistant Automation

Hi everyone,
I have a magic mirror running on a raspberry pi. I would like build an automation to shutdown the pi when I leave the house and over night and have it automatically startup when I am returning home or when my house switches back to “day” mode.

However I could not find an integration, also not on HACS and it is very hard to find anything by searching the web as all questions are about shutting down the Pi which runs Home Assistant, which its not my issue.

So if anyone has an Idea how I can control that other Pi from my HA that would be awesome. Thanks!

There are some ways to create sensors and switches for other raspberries on the network, based on MQTT.
RPi-Reporter-MQTT2HA-Daemon, home-assistant-pi, for instance… But I haven’t tried any of those.

Right now, I only have a Rasp3 b+ working behind the living room’s TV, that my kid uses for SteamLink.
I had an old RemotePi Board, from MSL Digital Solutions, (they are “permanently closed”, but you can easily find other alternatives to work as a IR/RF receiver). So it was quite easy to create voice commands, and scripts to Turn it On/Off, using a Broadlink.

It could be a solution…

I apologies for reopening this old thread but your question is exactly what I set out this morning to look for a solution to use for my use case which very close to yours.
Did you find a solution since then?

It can be accomplished with ssh and a shell command. I use the following to restart. I believe you need to remove -r for it to shutdown instead of restart.

shell_command:
  restart14: ssh -i /config/ssh/id_rsa2 -o 'StrictHostKeyChecking=no' [email protected] sudo shutdown -r

Follow this guide to set up the ssh keys.