Automation rule based on power outage?

Is it possible to create an automation rule based on power outage?

What I’m looking to do is turn off a smart switch once power has been restored after a power outage. I didn’t see a way to do this in the app. Do I need to write my own service that runs on a server of sorts?

There are multiple ways to do this depending on the exact devices that you have. See the project report section of the quick browse lists in the community – created wiki and look at the list for power monitoring projects. You’ll see several ways there. :sunglasses:

In theory, webCoRE has a Hub Power virtual device that should work IF you have batteries in the hub AND no UPS to power the hub AND enough juice in the batteries to successfully power the hub through the power outage AND if ST didn’t change anything to their power source messaging (undocumented). You should then be able to do something on

Power Hub changes to ‘mains’...

And yeah, that’s a lot of IFs…

1 Like

Does anyone have an idea how long the hub can run on fresh batteries?
When migrating to a new hub, I was running it on batteries to be able to easily get it to devices for pairing. I could not complete the migration on a fresh set of batteries and had to replace them halfway through the process. If I have to take a guess, I would say that I probably got about 5 hours from a set of batteries.

@ady624 I’ve tried the ‘Hub power source changes’ trigger, but it never executes my piston when I pull the plug on the ST hub. Oddly enough, however, webCoRE’s dashboard shows a battery icon under the hub status icon. I must be doing something wrong, right? :confused:

What version are you on? I can’t do much if you don’t share a piston.

This one here works:

full debug:

7/22/2017, 3:44:05 PM +676ms
+1ms	╔Received event [Home].powerSource = battery with a delay of 111ms
+453ms	║RunTime Analysis CS > 45ms > PS > 363ms > PE > 45ms > CE
+460ms	║Piston waited at a semaphore for 277ms
+464ms	║Runtime (35769 bytes) successfully initialized in 363ms (v0.2.0dc.20170722) (462ms)
+466ms	║╔Execution stage started
+482ms	║║Comparison battery changes_to battery = false (1ms)
+485ms	║║Cancelling condition #4's schedules...
+487ms	║║Condition #4 evaluated false (9ms)
+488ms	║║Cancelling condition #1's schedules...
+490ms	║║Condition group #1 evaluated false (state changed) (13ms)
+495ms	║╚Execution stage complete. (30ms)
+505ms	╚Event processed successfully (505ms)

7/22/2017, 3:44:05 PM +627ms
+1ms	╔Received event [Home].powerSource = battery with a delay of 65ms
+151ms	║RunTime Analysis CS > 53ms > PS > 65ms > PE > 32ms > CE
+159ms	║Runtime (35678 bytes) successfully initialized in 65ms (v0.2.0dc.20170722) (157ms)
+161ms	║╔Execution stage started
+177ms	║║Comparison battery changes_to battery = true (2ms)
+180ms	║║Cancelling condition #4's schedules...
+181ms	║║Condition #4 evaluated true (9ms)
+183ms	║║Cancelling condition #1's schedules...
+184ms	║║Condition group #1 evaluated true (state changed) (13ms)
+189ms	║║Cancelling statement #2's schedules...
+209ms	║║batt
+211ms	║║Executed virtual command log (10ms)
+216ms	║╚Execution stage complete. (56ms)
+224ms	╚Event processed successfully (223ms)

LATER EDIT: Looks like those events are not very reliable - I never got a power=mains event (checking the IDE) and then no more events were sent for subsequent battery/mains flips. I need to find another solution for this.

1 Like

Here’s a copy of the piston. I figured there was a lapse in communication between the hub and IDE. Let me know what you find. Power outages have become a nuisance lately!

For me the hub power restored message takes a few days to update for done reason, I have 2 pistons using the hub power virtual devices

I have ‘played’ with a few HA hubs before deciding on ST
So although my ST is on a UPS and unlikely to need a remote reboot, I put it on a z-wave socket and control that socket with a ‘Vera’ hub
Something similar could work for you if you could find a cheap 2nd hand hub from ebay. Anything that you can setup with a z-wave socket and configure
(The reason I chose the Vera to do this is because it doesn’t need an internet connection to function)

I’ve installed a canary light, which only comes on when power is restored, and have rules based on that. Maybe not the most elegant solution, but works for me.