Power Outage and Zigbee Bulbs

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.

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

1 Like

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.

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.)

1 Like

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.

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.

1 Like

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.

1 Like

@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.

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.

2 Likes

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.

1 Like

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.

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()
                               }
			}
		}
    

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?

I couldn’t find a simple way to tell that the power has been cycled. There is a field in the hub data that is batteryInUse. You would need to track when this gets set to Yes and then back to No.
The first issue is that getting that value is a pain. The only way I found would be doing an html request and then parsing the results.
The second (and more critical) issue is that when the power goes off, the internet goes off and the smartApp would stop receiving events, since it is not processing locally. This mean you would never get the initial batterInUse flag. This can be overcome with a UPS, but I would need a second one as I have Fios and would need a UPS for the phone switch and the router, since they are in 2 different locations.
I would much rather use an indicator coming from the hub, but until both of the above issues can be addressed, @JDRoberts’s suggestion for a canary bulb really is a brilliant idea. Beside only costing a $15 bulb, it is capturing the exact event that I’m looking for, Smart bulbs turning on due to a power outage.

I’m glad I could help out, I’m sure you will find another project for your first SmartApp.
If you tackle the issue of determining the hub lost and regained power, please share you code, as that may give me enough incentive to get another UPS.

1 Like

Is there a way in CoRE to push/request a healthPoll() on the bulb?

Power Failure - One Solution with CoRE

It looks like the healthPoll() function runs every 5 minutes. It is that which will see the bulb is now on/100 and update things. From the silence on this site, I take it there is nothing in core to run a healthPoll() like function.

Armed with the 5 minute cycle, I wrote a simple script that runs every 5 minutes. It tests if the light level is greater than 99. Why 99? I changed my other scripts to set the light levels to a maximum of 99 so that when there is a power failure, I can detect the bulb is set to 100 and thus a power failure occurred.

Before you begin, turn on Advanced Mode by going into Settings->ExpertFeatures->Expert Mode

FAR from perfect, but a start. It will break if the bulb is connected to a remote. My case is a stationary fixture in the bathroom used as a nightlight triggered by motion sensors. Just wanted to share.

Note since this also depends on the healthPoll() running, it could take 2 cycles or 5-10 minutes for this script to run and your bulb turn off.

Comments and ideas welcome.

1 Like

How do setup. Can you please give an instructions Thanks

I know this is an old thread, but I stumbled onto it and it made me think of my situation. I have (10) Cree bulbs scattered throughout the house. They work fime for me but they do have the issue of turning themselves on at 100% after a power outage. None of my smart switches have this issue. Even though I have a whole home generator, this still occurs during the 15 seconds it takes for the generator to fire up.

So after gathering ideas from @JDRoberts and the rest of you who’ve contributed to this thread, I decided to tackle this for my particular setup. I don’t have any unused Smart Bulbs to use as a ‘canary’ in the specific way that has been discussed here. BUT I do have one that is very rarely set to 100% and never when all (10) of the Cree’s are also on and set to 100%. Using that information and applying it to a webCoRE piston, I came up with the following:

I’ve tested this and it works perfectly! I hope it can be used for some of you as well.

Lee

3 Likes

Thanks for this! I have set it up and will see how it goes. I’ve only got a few zigbee bulbs but only one of them is sometimes triggered to turn on at 100% otherwise it’s at 20%. So I’ve used that as my canary bulb and in the piston which triggers that canary bulb to turn on at 100% I’ve changed it to set it to 99% so it doesn’t cause a false trigger of this power outage piston. With that done, I’ve removed the time condition from your piston as in my case, my bulbs will never be on at 100% unless there has been a power outage.

Great!
In case you’re interested, I’ve updated my piston a few times and this is the result:

This new version runs on a looping timer - I’ve got it set to 10 minutes currently. Looping seems to be more stable. Also, my canary bulb is now an on/off switch and not subject to the same issue as my Cree bulbs staying on at 100% after an outage. I also have the Cree bulbs dimmed to 20% before turning them off so that they don’t turn on at 100% the next time they’re activated.

Good luck!

1 Like