Make RM to shutdown both a Raspberry and Hubitat to protect DB in a blackout

Hi everyone, I know this request has been covered on other posts, but IMHO it has led us to a dead end.
I am trying to use RM to shutdown both a Raspberry AND a Hubitat hub after a blackout.
Actually I have three devices I want to take care of in case of a blackout; Synology NAS, Unifi Raspberry and Hubitat hub. (to prevent damaged DB´s)
I already solved the Trigger part of the rule via a presence sensor (Joelwetzel HTTP Presence Sensor at the NAS). I already took care of the Synology NAS by using HTTP PS connected straight to the UPS. I don´t have to go through HE to solve this because Synology to UPS works flawlessly. When the NAS shuts down in case of a blackout, the HTTP PS will detect the absence of the NAS (Trigger) and then I want to send the command both to the RPi with Unifi DB and the HE hub.
I know (maybe) I should use POST commands, but I also know that there is an issue with rights that need to be solved before sending the commands both to the RPi and HE.
Can anyone lead me to the right path? as detailed as possible.
All help welcome!!!

I’ll get you one step further. Because you’ve handled the trigger part (I use a power source switches to battery event from the Ring Alarm Extender Gen 2 for mine), the next piece (actually, last action for your Rule) is to shutdown Hubitat. To do that, install Dominic Meglio’s (@dman2306’s) Hubitat Hub Controller driver (installable via Hubitat Package Manager, also by Dominic Meglio) and do a shutdown() Actuator custom command on that virtual device.

2 Likes

Wow!!! That was quick!!! @672southmain you rock!!!

I just went through all the suggested processes and it worked flawlessly!!!

This solves half of my problem.

Now I need to send a Shutdown command to a Raspberry that holds my Unifi DB. If I don´t shut it down properly it gets damaged and sometimes this can be a real headache.

Any ideas or suggestions are welcome.

Again, thanks a lot @672southmain!!!

2 Likes

Hi all,

I´m still missing the procedure on how to shut down a Raspberry holding my Unifi controller (and DB). In case of a power failure, if the RPi loses power, and most of the time it will damage the Unifi DB and it´s an headache to bring it up again.

I know there must be a way to send a command, from the HE to the RPi, to shut it down properly.

I´ve even tried to modify Dominic Meglio´s Hubitat Hub Controller driver, with no luck.

I will appreciate any help. Thanks!!!

Much easier to go the other way. I use apcupsd on my SBC to detect when my SBC and Hubitats are on UPS power. And then when there's 15% power left, I use curl to shut down both Hubitats, and then run shutdown on the SBC.

Here's how you shutdown a Hubitat from an RPi or any other SBC using curl:

curl -X POST http://he_ip_address/hub/shutdown

3 Likes

@aaiyar thank you very much for your suggestion.

The problem I have is that I want to shut down THREE devices: a Synology NAS, a Raspberry Unifi controller, and a Hubitat hub. (To protect all files from being corrupted by improper shut down).

The Synology I already took care of it by plugging it straight to the UPS and configuring the option that Synology has for that specific purpose. (Works perfect!)

Now for the other two I am using a RM where this HE tool is supposed to be able to send commands to devices (Post).

The Hubitat hub I already solved it by using Hubitat Hub Controller driver from Dominic Meglio (@dman2306). It also worked perfectly.

But I´m still missing a command/configuration to shut down a Raspberry, sent from RM at Hubitat to a RPi.

Any ideas?

Use an ssh command from your Synology to shut down the RPi.

In fact, I would do the following - since your Synology detects the UPS status, I would use curl on the Synology and shutdown your Hubitat and ssh on your Synology to shutdown the RPi. There's no need for any app on your Hubitat.

2 Likes

@aaiyar Thank you for your response.

Can you be more specific?

Here is my problem; I don´t know how to do that from a Synology.

Being more descriptive;

a) I don´t know how to send an ssh command from the Synology NAS to an external device (RPi). Please guide me to the appropriate utility on the NAS to do such a task.

b) A BIG problem I have faced is how to make this ssh command work, including security, on that RPi. I must consider the user and password of the user on that RPi.

c) I don´t know how to send such a command from the Synology NAS when it detects a power failure from the UPS. (Trigger)

All help will be most welcome.

I don't have a Synology NAS, but here is what you will need to do:

  1. Get ssh access to your Synology (How to SSH into a Synology NAS – Marius Hosting)
  2. Set up password-less ssh between your RPi and your Synology. These instructions will get you going (2 Simple Steps to Set up Passwordless SSH Login on Ubuntu).
  3. Getting the RPi to shutdown from the Synology would be something as simple as:
    ssh user@RPi "shutdown -h now"
  4. I assume that the Synology has something similar to apcupsd to monitor your UPS. If so, the relevant files would be /etc/apcupsd (or its equivalent on the Synology). I would recommend using a Synology user group to get help with this ....
1 Like

Sounds logical, thanks a lot.

Will look at it tomorrow.

1 Like