Turn off an external raspberry pi

Hi there

I have a dedicated raspberry pi running Hyperion (ambilight) and it’s quite annoying having to go to the console (putty) and typing the typical “sudo shutdown now” command. I have been told that unplugging it may cause problems to the SD card.

So… is there a way to launch that script from HA? It would be a ssh command but I’m completely clueless on how to perform it on HA :frowning:

Once again the pi and HA are both completely independent from each other.

THANKS IN ADVANCE

What’s the point?

Shutting down the Raspi does you almost nothing, as it continues to consume power. And you can’t really get it back on?

Since rPi doesn’t power totally off on shutdown, your best bet is twofold: first you create a shell command to SSH to that system to shut it down and second you attach a smart plug to the power so you can turn it off after whatever amount of time you need for the shutdown to occur. Turning it on is as simple as turning the smart plug back on again.

Here is a good read on how to set up SSH key on the target so you can SSH to it easily and without a password:

Then you will simply create a shell command in Home Assistant for your shutdown:

After that you can write a script to run the shell command then wait X minutes and then turn off the smart plug:

It seems daunting but all of this is probably 15 minutes to put together and once you do it you’ll have some valuable knowledge for the future to do other cool stuff via remote shells.

I have my Hyperion pi plugged in a smart plug, I then use this

to turn it off, then after 3 minutes I turn off the plug.

If or when the telly is turned on after sunset the Hyperion pi is turned on, or if the telly is on before sunset then at sunset the Hyperion is turned on.

1 Like

And the safest command is “sudo ha host shutdown” - verify somehow it is shut down (maybe wait a minuite for it to close all files and finish etc.) THEN power down the outlet, THEN wait a short time, THEN power it back on when you want.

That’s a pretty cool integration, I’ll have to check that out. I wrote the exact same thing through scripting and shell commands.

Yep me too done it through shell commands in the past till I changed pi and could not remember what I did and all that key stuff was confusing me, found this and it was sorted easily.

Works like charm!! Thanks