[OBSOLETE] SmartBulb Power Outage handler

Thanks for the feedback and I’m glad to hear it’s working as expected!
I have pulled plenty of apps and code from the community. I’m glad I can contribute!

I finally had a short power outage today and the app worked turning off the bulbs that were off before the outage.
Next step is put the bulbs that were on back to their proper dimming level…

@nsweet
I am trying to get this to work with my OSRAM Lightify bulbs. I have 4 of these that are dimmable and can change white color. These bulbs do the same thing in that upon power restoration they go full brightness and on. I went and bought another that is not dimmable in any way basic on off.That one is my canary.

I installed new bulb into smart things fine but it came up as a dimmable zigbee switch. I changed it to a regular Zigbee switch. I can turn it on and off fine with either type selected.

I installed the smart app, then tried to configure it. I get this error in the live logging.

27eee8e7-beab-4d65-9fc0-7fb7b94cb4c0 ‎6‎:‎18‎:‎37‎ ‎PM: error java.lang.IllegalArgumentException: Command ‘poll’ is not supported by device 4233d37d-8286-451e-99b7-da255a9f46df of type ‘ZigBee Switch’. Supported commands: [on, off, configure, refresh]

Way I see it the bulb (canary) says it cannot support the poll command. So will this not work with these bulbs? I hope I am just missing something simple.

Any breadcrumb or pointers in the right direction would be much appreciated.

You could try to change the device to a cree or ge link bulb and see if that works.
Otherwise you could change the SmartApp and replace .poll() with .refresh().
(i.e. canary.poll() would become canary.refresh()).
As long as your other bulbs support refresh you should be okay. Otherwise I’ve seen another app (?pollster?) where it had two selections when setting up the app. One of things to poll and another of things to refresh.

Hope this helps. Let me know how you make out.

1 Like

actually, since only the canary needs the refresh, you could just change the canary lines and you should be good to go.

@nsweet

I got the App to go without errors by changing everything to .refresh on both the canary and slaves.
Now when I turn the canary on, (in live logging) it looks like it runs and restores one of the bulbs. The others don’t change.
I just realized another possible hiccup. 3 of my bulbs are controlled by a grouping smart app. Also all 4 of the other bulbs I’m trying to turn off are dimmable. I see in the live log a off followed by level 0 on the next line.

I’ll have to wait until daytime to play any more as the lights are kinda needed right now and the family won’t like me turning them off and on!

Thanks for your help so far

I don’t think the dimming will make a difference, most bulbs will come on at 100% when the power is restored. The grouping app could be affecting things.
Also, I’m not sure of the differences (if any) between polling and refresh. That may affect things, but as far as I know, I think they should both work. (any experts out there, feel free to chime in!)
Basically the app is checking all monitored bulbs every time a bulb is turned off or on via smartthings and saving a list of the bulbs that are off (you should see this in the live logging).
The polling (refresh) is done every five minutes to pick up any state changes that may have been missing. This was mainly done for the cree bulbs that don’t report a change if they are turned on by a physical switch.
Additionally, if the canary bulb is on, it doesn’t check the state of the other bulbs, as the assumption is they are all on due to the power being restored and we don’t want to capture this state.

When the app sees the canary bulb is on, it simply turns off the canary and then turns off any lights in the list of lights that were off.
Testing is a little difficult unless you are willing to flip the main breaker of your house or have all the lights you are testing on the same circuit. I tested with a subset of lights that I was able to turn off and on together.

Hopefully this will help with your troubleshooting. Keep me posted

When you turn off the light switch and turn it back on a few minutes later, does the SmartApp still show that it’s off?

Some bulbs can detect that they’ve been turned on, like GE Link Bulbs, but others like Cree Bulbs don’t.

Polling the device is the workaround for the bulbs that don’t, but if you’ve removed the polling feature and the light doesn’t report that it’s been turned on, I doubt you’ll be able to use it as the canary.

All bulbs I’ve seen turn on at 100% when the power is restored so using a dimming bulb as the canary shouldn’t cause any problems.

From looking at the device types for the Cree bulb and GE Link, poll() does a ZigBee on/off refresh and level refresh and refresh() does the same plus a ZigBee on/off config and level config. I’m not sure what the ZigBee config does but it would appear that refresh should still take care of the issues with Cree and the like.
However the checking of the bulbs happens every five minutes, so if you turn the bulb off and on with the physical switch, it may take up to 5 minutes for the app to be in sync with the bulb(s).

If the power goes out before the poll/refresh cycle then the those bulbs may still be considered “off” by the app.
I’m not sure what state is reported by a poll/refresh if the physical switch is off during the poll.

I’ve updated the code (both in GitHub and in the posts above) to handle devices that don’t do polling, but do refresh.
It polls if poll is available, otherwise it does a refresh.
To test, I changed a Cree bulb to a ZigBee Switch device type, which refreshed and picked up the correct state.
If your device doesn’t poll or refresh, then throw it away :smile:

2 Likes

After updating to the latest code you posted above everything seems to be working. I took my canary, one lamp not in the dimmer group, 1 lamp in the dimmer group put them all on 1 extension cord so I could control power application.

At first for whatever reason I couldn’t get it to work. So my usual first troubleshooting step is to reinstall everything. So redid the smart app code. Opened it and selected only the canary and bulb not in group. Worked like a champ turns them off before they can even get full brightness.

Next I added the lamp from the group, it didn’t work?? So I removed it from the group app. Then tested and it worked. So you would say to yourself it’s the group app.

So I put the lamp back into the group control app. Low and behold it works?? I can still control the lamp using the group app, or individually using the smartthing android app.

So I have no idea why the change. Gremlins??? Doesn’t really matter it appears to be working.

Thanks again for everyone’s help.

I’m glad it’s working for you and thanks for finding the issue with devices without polling.

The “Gremlins” may be the group (depending on what the group is doing). This is from another post:

If the packets arrive in order, then all is well. If things get out of order, then the group may be changing things before/after the SmarterBulb app and you get odd results.

I have sets of bulbs in my setup that I control as a group, but always use a virtual switch as the controller. The SmarterBulbs App is always controlling the individual bulbs.
I dont’ have any smartapps that are tyring to set the state of one bulb bases on the state of another bulb.(except for this one).

2 Likes

Nick, thanks for doing the app. We’ve got 100 odd devices, and came home last night to 40 odd lights on at full brightness. I installed the app + “canary” light and tested by shutting off our two power panels for a few minutes.

With batteries out of the Smartthings hub, the lights stayed on after the “outage”…so I’m guessing you need cells in there for the code/timing to work correctly? I don’t have a UPS on the ST hub.

With batteries installed in the ST hub, the lights went off as they should after power was restored. Being that ST has resolved the leaky battery/drain issue (we hope), I’ll just leave some rechargeable cells in there.

Cheers,
Dennis.

Maybe? I didn’t think they would be needed, but it might affect the timing of things if the hub has to boot after the power is restored. (or maybe the hub reboot causes the app to reset, clearing the settings?)
Since this is a custom app, it is processing “in the cloud”, as opposed to on the hub, but there still might be some timing issue.
Additionally the check of the canary bulb is every 5 minutes, so you may have to wait a bit before the lights shut off.
Glad the app is helpful!

1 Like

I installed this smartapp through Smartthings IDE. However, every time I try setting it up I initially get a green notification banner saying “Smarter Bulbs is now installed and automating” but then soon after a red banner with “An unexpected error occurred”. It’s baffling me.

Any ideas please?

Have you checked the Live logging in the IDE to see if it gives any clues to the issue?
I don’t think I’ve seen any issues with the installed app on my hub, so I don’t think it’s a global issue.
What devices are you using for the “canary” bulb and to sync?

Live log whilst installing:

18:43:26: error java.lang.IllegalArgumentException: Command ‘poll’ is not supported by device of type ‘ZigBee White Color Temperature Bulb’. Supported commands: [on, off, configure, setLevel, refresh, setColorTemperature, ping, off, on, setGenericName] @ line 52
18:43:26: debug Installed with settings: [canary:IKEA Trådfri bulb, slaves:[WeMo Kitchen, WeMo Landing]]

Any ideas? Thanks

Make sure you use the second post with the code further down the thread. The original code used a “poll” command, which isn’t supported by all devices. The later posting fixes this issue and will use a “refresh” or a “poll” depending on the device capabilities.

Still getting “An unexpected error occurred” when installing the various versions in this thread.

I’ve given up on this now and using Smart Lighting instead to control items after a power cut: (1) If canary light is on then switch off smart bulbs; (2) if canary light on switch on all smart switches.

Got the same issue as you on installation. … a smart things quirk?

Curious as to how you set your canary bulb up

Could you share please

Many thanks