Power Outage and Zigbee Bulbs


(Nick) #1

After a power outage, zigbee bulbs (cree GE, etc/) all turn on. I know there has been a lot of discussion about this, but I haven’t seen any apps to try and address the situation.
First, is there an easy way to get the current value of “batteryInUse” from the hub data?
If so then, what about an app that cycles every few minutes. If batteryInUse then set a flag, not batteryInUse and flag from previous cycle was not batteryInUse, then It records the state of selected devices. If not batteryInUse and previous cycle was batteryInUse( i.e. the power is back on), then set selected devices to their previous state.
I know that this isn’t perfect and things may change in the physical world between the time the power comes on and the hub goes online, but this should be close enough. I’m looking more at the short minute or two outage at 3 AM and not having to get up to shut off lights.

I’m guessing the biggest hurdle is that this has to run local. Any way to create a device that polls the batteryInUse and have an approved locally run smartapp do the turning off?


[RELEASE] SmartBulb Power Outage handler
#2

There are as yet no custom smart apps approved to run locally. The only smart app that can run locally is smartlights and a small part of smart home monitor.


#4

I can’t remember if there any device is eligible to run locally that have lux reporting. If they do, that’s an easy fix-- set up a “canary” bulb somewhere where it would never normally be on in the middle of the night.

If the lux in that room is higher than expected late at night, you could automatically turn off all your local zigbee bulbs.

My main concern with this is what if the outage is due to a natural emergency like a lightning strike or even a fire and you want your lights on to help with home evacuation?

Personally, I would be more likely to set up my house so that I could just turn all the lights off with a button push from a minimote if I didn’t feel it necessary to inspect each room.

JMO


#5

Another MacGyver option (don’t ask me how I know this one):

Put the canary bulb in a short table lamp.

Put any locally eligible PIR motion sensor on the shelf just below the lamp. May have to experiment a little with placement.

You should be able to have it set up so that the motion sensor fires whenever the light comes on. It doesn’t take a lot of heat if the distance is close enough.



(Dale C) #6

I can’t even remember the last power outage I had… I guess I’m lucky or just my memory is going :wink:


#7

Just depends where you live. We get an outage three or four times a year. :sunglasses:


(Nick) #8

The issue for me is getting up in the morning and finding a bunch of lights on the first floor have been on all night. I would guess that if the outage is due to an emergency, it won’t be coming back on. If it does, the lights that I want to shut off would not be in my primary evacuation path anyway.

The canary bulb idea is interesting, but you’d think there should be a way to do this programmatically rather than spending $50 on hardware just for this purpose.

I do appreciate you input! Thanks


#9

The “canary” Bulb can be one that you do use as part of your regular set up in the evenings when people are awake, just not one that is typically used after people have gone to bed.

If there’s a device that can run locally that has lux readings, you may also be able to use it for other purposes as well.

So just depends how you have things set up.

I agree, though, it would be nice to be able to do this just by reading the hub variables.


(Chick Webb) #10

That is a gem, @JDRoberts, even compared to many of your others. :triumph:


#11

BTW, as I Think about it, I think you could also just do it with two smart lighting automations:

If the Canary light comes on during a specific time, turn all the other zigbee lights off.

If one of the other zigbee lights turns off during the same time period, turn the Canary light off.

So you don’t need any extra equipment. :sunglasses: You just need one bulb to act as the Canary that you generally expect to be off all night. If it comes on, there must’ve been a power outage, so turn all the other lights off. You can still use the Canary light the rest of the time.

Again, though, you have the problem that if people are up in the house because of the power outage, the lights may turn off around them.


(Nick) #12

I’m also looking to address the issue when the lights come on during any time of the day. We’re often away for the weekend and come home to find lights on.
This would still work if I use a canary bulb that is not used for anything else. (a $15 investment).
Additionally, to avoid shutting lights off on people where they were on before the outage, I still would like to save the state of selected bulbs (I’ve seen a smartapp that was doing this for some reason, I’ll have to hunt it down).
So, if canary bulb is off, then save the state of the selected bulbs, if the canary bulb is on, return the bulbs to their prior state and turn canary off.
Since both of the functions needed above happen while there is power, we don’t need the smartapp to function while the hub is offline.
I’m guessing the app should cycle and check to see if the canary bulb is on, rather than subscribe the bulb’s power on, as the bulb will come on before the hub reconnects and I’m guessing the event would be missed. Also would like this to work if the batteries die during the outage.
So anyone feel like writing this?:grin:
(I am a developer, but not in the javascript/groovy world, so it will take me a while to muddle my way through it.)


(Dan) #13

I’ve addressed this problem with a SmartThings version 1 motion sensor, and a custom smart app written by a community member. The v1 motion sensor runs off battery and USB power and sends an alert when it switches power source. This allows me to get both notifications when the power goes out and is restored, and to use this as a trigger to turn off all the connected bulbs (GE / Lifx in my case). It seems to be working fine last time I tested it.

It does require the cloud, and there may be issues if the cloud is still unavailable when the power comes back on and the event is missed. But so far it seems to be working ok. My hub and router is on a UPS, and I haven’t had a power failure long enough to drain the UPS since this was implemented. That is why I like the outage notification, then at least I know that I need to check periodically.


(Nick) #14

I’ve looked at that solution. Apparently version 1 motion sensors are hard to come by. Also I’m more concerned about the lights coming on when the power is restored more than the notification of the outage.
I’ll get the hub offline notification if there is a power outage, although I won’t know if it’s power or just internet.


(Fast, Good, Cheap...pick two.) #15

I had the same scenario as @Dan999

It works when the power is off for long enough for things to cycle.

More often than not my power cycles are very brief…so brief the only way that I know is all my bulbs are on and the long “beeeeeeep” from my backup power supply. At most I might see a slight flicker.

Because these are so brief the power cycle is not caught by the V1 motion sensor / app method, rendering it quite useless.

I think z-wave dimmer modules and dumb leds are the way to go for the bulbs in question and I plan to convert all that I can eventually.


(Benji) #16

@ajpri was looking into writing an app that would do just this.

With that being said, all the lights are still going to turn on first for a few minutes until everything gets back online.


(Austin Pritchett) #17

I was indeed working on something…

I was going to release of a preview of it last week, but my power went out and proved it unsuccessful… On the day I was going to release it…

That said, I am still working on something. However, both the hub and modem/router must have some form of power backup. That was the only flaw. My router (OnHub) had to finish starting up.


(DanG) #18

For those that know how to solder you can purchase a relay and wire it to a open/close sensor. When the power fails the relay opens which in turn signals the open/close sensor. When the power is restored the open/close sensor changes states so you can use any of the many apps to turn these bulbs off once power is restored.


(Dan) #19

Everybody has slightly different requirements and failure scenarios, as well as equipment setup (router / UPS, etc). In our case, power is very stable (touch wood). We get outages once or twice a year, if that, and it’s normally associated with weather events. Or some (texting) driver taking out a substation, which was the last power outage we had. We never, or very rarely, get brownouts that trigger the smart lights to come on.

If the lights come on in the middle of the night due to a power failure / restore, then even if the system works, it will probably still wake us up, due to the delays in triggering and running the smartapp. I have a Iris 4-button controller on my night stand that I can use to re-run “good night” which will turn off all the lights and let us get back to sleep. I’m more concerned with when we’re out of town and we get a power failure on the first night, and the lights are on for the rest of the time. Therefor the redundant notification of power fail / restore as well as the smart app to turn off the lights when the power comes back on.

I agree with @Drewbert34 that if your main concern is having the lights behave predictably, then use dumb lights and a smart switch. We use that in most cases, but we use our smart lights for notification as well as supplementary lightning.

That said, this definitely seems like something that can be baked into Hub V2 as a reliable local feature.


(Nick) #20

Thanks again to @JDRoberts for coming up with the idea of the ‘canary’ bulb (and the name).
Below is working code which should do the trick ( groovy/JavaScript is not my forte, so don’t laugh if the code is a bit rough around the edges).

Basically it records a list of the bulbs that are off whenever any of the slave bulbs change state and the canary bulb is off.
Then, if the canary bulb comes on, it turns off any of the bulbs that were off the last time the states were saved.
If also polls every 5 minutes to see if the canary bulb is on, just in case the on event was missed due to the hub being offline due to the power outage.

Works with my simulated power outages (turned some bulbs on, some off, pulled the network cable from the ST hub, flipped the manual switches on each light/lamp with a slave bulb and the canary bulb, plug the network cable back into the ST hub).

definition(
	name: "Smarter Bulbs",
	namespace: "smartthings",
	author: "nick@sweet-stuff.cc",
	description: "Save the state of a bunch of bulbs and reset when 'Canary' bulb turns on",
	category: "My Apps",
	iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld.png",
	iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld@2x.png"
)
preferences {
    section("Canary Bulb") {
        input "canary", "capability.switch", title: "Who sings?"
    }
    section("Zigbee bulbs to monitor") {    
        input "slaves","capability.switch", multiple: true
    }
}

def installed() {
    log.debug "Installed with settings: ${settings}"
    initialize()
}

def updated() {
    log.debug "Updated with settings: ${settings}"
    unsubscribe()
    initialize()
}

def initialize() {
    subscribe(slaves, "switch", saveStates)
    subscribe(canary,"switch.on", checkRestore)
	runEvery5Minutes(checkRestore)
    saveStates()
}

def saveStates(evt) {
	if ("off" == canary.currentSwitch ) {
    	def lightsOff = [:]
    	slaves?.each {
			if (it.currentSwitch == "off"){
        	log.debug "${it.id} value ${it.currentSwitch}" 
        	lightsOff[it.id]="off"
        	}
		}
   	state.lOff = lightsOff
	}
}

def checkRestore(evt) {
   
    log.debug "Canary is ${canary.currentSwitch}"
    if ("on" == canary.currentSwitch) { 
    	log.debug "Turning stuff off"
        restoreState()
        }
    canary.off()
}

private restoreState() {
  slaves?.each {
				if (state.lOff[it.id] == "off") {
                log.debug "turning $it.label off"
				it.off()
                               }
			}
		}
    

(Patrick Shoemaker) #21

I was just about to start my first attempt at writing a SmartApp for exactly this, so thanks Nick for beating me to it. Why did you decide to go with the canary bulb architecture instead of the V2 hub power state? Is the power state “debounced” enough that it misses short outages that trigger bulbs to come on?