This is awesome! Power is Out based on state of v1 Motion Sensor

Just to confirm this… Thanks. Unbelievable that SmartThings updated the deviceType, which broke this, and has had no answer to my reports about it over the past two months. )c:

Not to mention there are TWO SmartSense Motion Sensor deviceTypes in the templates, which are identical (and don’t work in this regard).

IIRC, the aeon doesn’t support the powersource state.

1 Like

Aha. OK then. Thanks for the response. :slight_smile:

Did you ever find a device type version that still reports line status? I just noticed now this was broken. Ugh.

Yeah… Some time ago they updated the stock deviceType and mine is working again, unless they broke it again since then. Frankly, I’ve run out of patience with this platform and don’t have the time to continually double check what’s working and what is not.

3 Likes

Does anyone have a link to the original code for this app? The link above to the second version (with device control) appears to be broken.

Also, was this ever modified to use the power state of the V2 hub?

Used this in a Google search: description: “Alert me of power loss using motion detector’s change from wired-power to battery-power. SmartThings hub and internet connection must be working! You can connect the hub and internet connection device (e.g. modem, router, etc.) to a battery backup power strip so that the motion detector and detect the loss and the hub and router will still have enough power to get the message out before they fail as well.”

Here are some hits:

You can’t use the powerstate of the hub unless you let the hub run on the AAs. You’re going to get much longer life from your hub if you connect it to a UPS like mentioned above. So if you do that (recommended), then the hub won’t see a power loss until the UPS dies. That’s why it’s set up to use a different device. I wanted the hub to stay on as long as possible, but still know when the power was out. I’ll dig around for the updated version. I did the original one (in this post anyway), just found this thread! It wasn’t the original though, I based it off a simpler one that didn’t notify when power came back on… I’ll work an update and post.

1 Like

Thanks @scottinpollock! I was realized this isn’t working, and was searching to see if the DTH changed, and found this post! To be fair though, the idea wasn’t 100% mine, there was a older smartapp that used this idea, but I expanded on it (and didn’t think at the time to post the other author’s name in the smartapp to give credit). Anyway, looks like there are still problems with this, I assume as everyone posted that something happened to the DTH. If I figure it out again, I’ll repost.

Do you still have a copy of your modifications? The link is broken. Adding the capability to turn things off/on after outage was on my to do list, so thanks for your efforts!

I got it working again. I think the only real change needed was to go into edit device on within the app so that SmartThings got a refresh on it. But, in order to consolidate all that is out here, here are links for the SmartSense Motion v1 Device Type Handler and the Smartapp again. I did modify both of them. For the DTH, you can now see if it’s on battery power or AC power in the device’s page. Hopefully I’ll hear back from someone to get a copy of the smartapp code from @scottinpollock (posted above). If not, I’ll get to work adding the same capabilities to my code, having the app turn off lights, etc that turn on when power is restored.

1 Like

Here’s the deal… Jesse copyrighted his SmartApp. And while I made changes to it for my own use, and posted those changes for a while, after I actually thought about it, I felt it wasn’t the right thing to do. This whole platform is a bit of a mess, with no way for developers that want to make a buck off of some scripting to tokenize their code. It’s all out there for anyone to see. So if ya wanna share it; don’t copyright it.

And if you wanna try and make a buck of it, well I think you’re just foolish given the way things are currently.

With all that said, my mods were pretty damn simple. Set up some inputs for the lights you want to turn off, and any that you wanna turn on if it’ll be dark out.

section("Make changes to the following when powered is restored..."){
    	input "offSwitches", "capability.switch", title: "Turn these off", required: false, multiple: true
    	input "onSwitches", "capability.switch", title: "Turn these on if after sunset", required: false, multiple: true
    }

Then add them to the on event handler:

if ( offSwitches ) {
    	log.debug "killing Hues"
    	offSwitches.off()
	}
    if ( onSwitches ) {
    	log.debug "restoring Hues"
        def ss = getSunriseAndSunset()
        def now = new Date()
		def dark = ss.sunset
        if ( dark.before(now) ) {
    		onSwitches.on()
        }    
	}

For anyone who’s not aware, there’s a new app that can handle smart bulbs during a power outage. See here:

Hey, that’s pretty neat! Thanks for sharing. Nice option for when the v1 Motion sensor dies.

Thanks @scottinpollock, I updated my code, version 1.2 is now in Github, link below. I, like others obviously, haven’t paid much attention to the copyright, you bring up a good point. It is a mess, with people just following what others have done without thinking. I’m going to put some thought in and go in and change all mine after. For now though, obviously this is out there for others to use, and if you have update/change suggestions, shoot them my way and I’ll get it incorporated.

https://github.com/flyjmz/jmzSmartThings/blob/master/smartapps/flyjmz/power-is-out.src/power-is-out.groovy

1 Like

Not sure if this has an “on battery” indicator, but it has both battery and USB power options, so it might work for anyone who can’t find a v1 Motion sensor.

There is a community created device type for this here:

But it doesn’t appear to have any indication of power source, not sure if it’s capable of reporting this or not.

Hope this helps!

Feel free to grab the code from my SmartBulb Power Outage app to return lights to their prior states. You could use another input section with "auto set " lights and then you can mix and match what you want the lights to do, some return to previous, some on, some off…
(and ignore the copyright stuff, just followed other apps, but an going to remove it!).

Thanks for posting this, I had used other versions and for whatever reason the outage and recovery sensing was always 20+ min after the fact. Just tested this and it worked great. If you wanted to make an addition, adding contact book integration would be great. I know not everyone has it yet, but I think most people who use the community site probably have it.

Just updated in github with partially what you’re getting at. I referenced your code, and now there is an option to select which lights you’d like it to restore the state (on/off) of.

Good idea! I’m going through all my apps and getting that added. Just got this one fixed up. Updated in Github.
https://github.com/flyjmz/jmzSmartThings/blob/master/smartapps/flyjmz/power-is-out.src/power-is-out.groovy

1 Like

I know this is an old thread but I’m wondering if this Smart app could be adapted to work with the Z-Wave Power Outage Sensor. That motion sensor also uses both battery and USB power.