Smartapp dev - ability to 'pulse' a hue bulb

Hi all,

Quick dev question: I’ve written a smartapp enabling me to make changes to the colour of my hue lamps depending on activities in the house, i.e. external doors opening. I’ve written my own because I couldn’t find an existing app which would give me the control I wanted.

I’d like to apply the ability to pulse the light - during the ‘alert’ condition I’d like to pulse the light by changing its dimmer level from 50% to 100% and back again recursively until the alert condition ends, eg the door closes.

Does anyone have recommendations on how best to do this? I’d like the level change to happen every 2 or 3 seconds. Would runin be a good candidate?

Also, how do I determine the currently level of the bulb? Do i have to subscribe to the bulbs setLevel in order to read the current level from the event data? Not sure how best to access this information.

If anyone has any advice I would be grateful.

Runin won’t work with the kind of precision you require.(ref. ST docs).

You can do it as a private method, but even that is unreliable, as it depends on the ST cloud scheduler. I do something similar in a laundry done notification smartapp. It always works, but not necessarily for the duration or number of flashes specified. See “The Flasher” smartapp for example code.

I think your requirement would be better accomplished at the hardware level. For example, the Aeon micro dimmer has a a blink/flash/strobe function that can be used by SmartThings as a visual alarm, and it is 100% rock solid. Check this thread for ideas.

Are these Hue bulbs connected through the Hue bridge? Does your app send a setColor() command?

That’s great. Thanks for the pointers, I’ll have a look into those options.

@Sticks18, yep lights connected with a bridge and the app is using the setcolor command.

I haven’t confirmed it works, but you could try adding the alert field to your setColor map with the value “select” or “lselect”. “select” should make the bulb flash once. “lselect” should make the bulb flash several times over about 15 seconds. Either one will end by itself, but if you send “none” before the “lselect” has finished it should stop immediately. (FYI - the Hue integration defaults to sending “none” in that field)


value = [hue: hueValue, saturation: satValue, alert: “select”]

@Sticks18, thank you. That worked perfectly. Much appreciated.

1 Like