Power Outage trigger to ST via Raspberry Pi, Webhooks, IFTTT


(Harley) #1

Wanted to share with this community. My UPS has USB for monitoring via a connected PC. I didn’t have an extra PC, so I bought a Raspberry Pi and figured out how to get Raspbian to talk to my UPS. It can now sense outages in under a second (I chose every three seconds). Notification is then sent by a PERL script that monitors the output of upsc, using curl, to Maker Webhooks, and via IFTTT this can cause nearly any change within Smartthings.
Please let me know what you think.
Code, steps, and hardware are at this link:


So this is going to work in a situation where the power is out but you still have Internet access, right? So if you are running your router on a UPS, you can send out a notification via IFTTT that the power has gone out.

As far as what your hub will be able to do if The power is out but you still have Internet access and the hub itself is not running on its own battery power but is running on a UPS, it will still be able to communicate with any battery powered devices. It won’t be able to communicate with any mains powered devices that don’t have power, obviously.

I just mention this, because people are often looking at “power management” in terms of six distinct use cases:

One) the power is out for the whole house, the hub and the router are operating on a UPS, Internet is functional, and the smartthings cloud is available

  1. Power is out on a single branch, the hub and the router are still on mains power or on a UPS, Internet is functional, and the SmartThings cloud is available

  2. Power went out and was restored, everything would be available, but the router needs to be rebooted

  3. Power is available, but the Internet is out

  4. The hub is running on its own battery power. In this case it won’t matter whether the Internet is available or not, because the hub won’t use it.

  5. power is available, the Internet is available, but the SmartThings cloud is unavailable

The solutions for each of these will vary.

Since your solution requires that IFTTT be able to talk to your SmartThings cloud account, and your smartthings cloud account be able to talk to your hub, so it looks like yours will fit use cases one and two above, May fit three, but will not fit four, five, or six. Did I get that right? :sunglasses:

(Harley) #3

Maybe better shown in terms of possible points of failure.
If power feeding the UPS fails (breaker, or mains), then my method relies on a good battery/charge on the UPS, USB cable to the Raspberry Pi, power to the Raspberry Pi, a stable OS, PERL/curl/upsd/upsmon all functioning, Webhooks server working, IFTTT (execution happening on your smartphone?) working, Smartthings cloud working, internet connectivity up, and Smartthings hub operating.
Certainly a lot of points of failure. While several of them might fail in the case of a widespread disaster, these things are quite stable in my case on a normal day… my power is what is unstable.
If you have two UPS’ and two Raspberry Pi’s, you could expand this solution to ensure it’s not just a breaker flipped.