Hue devices - adding support for effect and alert attributes of bulbs

Smartthings supports HUE integration by talking to the hue hub, but Hue supports two attributes on the bulb itself that Smartthings doesn’t expose

effect: “none”, “colorloop” - the colorloop effect is sorta a demo mode, but it is pretty. More importantly if your bulb is in colorloop, any other changes you make to it are ignored. You need it set back to effect:none to have other settings take.

alert: “none”, “select”, “lselect” - select flashes a bulb once. lselect flashes a bulb for 30 seconds or less if you set it back to none.

I’ve added support for these to the base ST implementation - you need to change the hue bulb device type, and the hue hub smart app to make it work.

The effect and alert attributes of the bulb reflect the current state of these from Hue, and the setEffect(s) and setAlert(s) commands were added to allow Smart Apps to change them. I added a couple tiles to the bulb device type to fire alert select mode, and toggle the colorloop effect.

If anyone is interested, I can post them up.

1 Like

Here are the diffs

Hue (Connect) SmartApp template changes

$ diff stapp.groovy stappnew.groovy 
12c12
<     name: "Hue (Connect)",
---
>     name: "Hue (Connect) with Effects and Alerts",
538a539,541
>                             sendEvent(d.deviceNetworkId, [name: "effect", value: bulb.value?.state?.effect])
>                             sendEvent(d.deviceNetworkId, [name: "alert", value: bulb.value?.state?.alert])
> 
547c550,553
<                             }    
---
>                             }
>                             sendEvent(d.deviceNetworkId, [name: "effect", value: "none"])
>                             sendEvent(d.deviceNetworkId, [name: "alert", value: "none"])
> 
554a561
>         log.debug("put response");
567a575
>                         
579a588,593
>                             case "effect":
>                                 sendEvent(childDeviceNetworkId, [name: "effect", value: v]) 
>                                 break
>                             case "alert":
>                                 sendEvent(childDeviceNetworkId, [name: "alert", value: v]) 
>                                 break
621a636,645
> def setEffect(childDevice, desired) {
>     log.debug "Executing 'setEffect'"
>     put("lights/${getId(childDevice)}/state", [effect: desired])
> }
> 
> def setAlert(childDevice, desired) {
>     log.debug "Executing 'setAlert'"
>     put("lights/${getId(childDevice)}/state", [alert: desired])
> }
> 
631c655,656
<     put("lights/${getId(childDevice)}/state", [hue: level])
---
>     // optional - turn off effect if any color change is made
>     put("lights/${getId(childDevice)}/state", [hue: level, effect: 'none'])
639c664,665
<     def value = [sat: sat, hue: hue]
---
>     // optional - turn off effect if any color change is made
>     def value = [sat: sat, hue: hue, effect: 'none']

Hue Bulb Device Template Changes

$ diff bulb.groovy bulbnew.groovy 
18a19,22
>         command "effect"        
>         command "effectCL" 
>         command "alertToggle"        
> 
19a24,26
>         
>         attribute "effect", "string"
>         attribute "alert", "string"
32a40,48
>     standardTile("effect", "device.effect", inactiveLabel: false, decoration: "flat") {
>         state "default", label:"Reset Effect", action:"effect", icon:"st.lights.philips.hue-single"
>     }
>     standardTile("alert", "device.alert", inactiveLabel: false, decoration: "flat") {
>         state "default", label:"Alert!", action:"alertToggle", icon:"st.lights.philips.hue-single"
>     }
>     standardTile("effectCL", "device.effect", inactiveLabel: false, decoration: "flat") {
>         state "default", label:"ColorLoop Effect", action:"effectCL", icon:"st.lights.philips.hue-single"
>     }
59c75
<     details(["switch", "levelSliderControl", "rgbSelector", "refresh", "reset"])
---
>     details(["switch", "levelSliderControl", "rgbSelector", "refresh", "reset", "effect", "effectCL", "alert"])
145a162,178
> def setEffect(v) {
>     log.debug "setEffect: ${v}, $this"
>     parent.setEffect(this, v)
>     sendEvent(name: "effect", value: v)
> }
> 
> def setAlert(v) {
>     log.debug "setAlert: ${v}, $this"
>     parent.setAlert(this, v)
>     sendEvent(name: "alert", value: v)
> }
> 
> def alertToggle() { 
>     log.debug "Executing 'alert select'"
>     setAlert("select")
> }
> 
150a184,192
> def effectNone() { 
>     log.debug "Executing 'effect none'"
>     setEffect("none")
> }
> def effectCL() { 
>     log.debug "Executing 'effect colorloop'"
>     setEffect("colorloop")
> }
> 

If you want to use these, you need to install a direct copy of the Hue Hub device type (just make a copy from the template and save it) - then you can use your self-published Hue (Connect) App to discover your hub as before…

You’ll be able to see the current values of the effect/alert in the state of the bulb, and you can change them from the tile or from an app. Enjoy. Maybe ST can update their base code to include these, in some form…

Edit: Need to add setEffect and setAlert to the commands section if you want to be able to call them from a SmartApp.

5 Likes

This is great! Thanks for sharing.