What is the best way to mimic Hue Dimmer Switch with Pico Remote?

OK, I have mulled it over and decided I can see other use cases for the Pico remotes, and I earned a gift card at work, so will buy the Lutron Caseta Pro Bridge kit :grin:.

I would like to make the Pico act the same way that I have the Hue Dimmer Switch programmed: On, 1 press = bulb on, 2 presses = nightlight scene, 3 presses = relax scene, 4 presses = read scene, 5 presses = concentrate scene, 6 presses = energize scene. Another press starts over with nightlight scene. That functionality is implemented with a state variable, which gets reset when Off is pressed (and the bulb is also turned off). Then the Dim Up and Dim Down will dim a certain amount when pressed and a different amount when held.

I don't think Hubitat supports Hue scenes, but I can extract the settings for the color temp and dim and just hardcode those. I have not tried it, but can I send color temp and dim to a group in addition to a bulb? Trying to avoid the popcorn effect with the 3 bulbs in our bathrooms.

Can I do this and if so, can I do it with one or more of the built-in apps or will I need to write my own app?

1 Like

yes, this does work.

The state counter that tracks your "scene" rotation is the issue, button controller doesn't have a way to implement that.
I would venture it could be done in some roundabout way in RM, but that adventure would likely take more time than modifying your existing app.

It's not clear if you have an HE app already using your hue dimmer, or if that's the way the hue dimmer interacts with the hue bridge.
In any event, as far as HE apps go that application would not be difficult if it would be your first.

2 Likes

Exactly what I needed to know, thanks!

Right now I have a ton of hand-coded rules in the Hue Hub, programming 5 of the dimmers, to do the scene rotation. The Hue app will program most of it, but I wanted the first press to react differently than they coded. It's lots of repetitive code and the new Hue app wiped out all the rules for one of the dimmer switches when I renamed it :confounded:. So moving all that functionality out of the Hue hub would be great.

I currently have a Filter Change app so I can use that as a springboard and write an app to run the Picos. I think it will be fun to write, and as you say, doesn't sound too difficult!

2 Likes

That would be handy. Looking forward to your app!

Don't suppose anyone happened to work on something like this yet? :slight_smile: I've finally started using my Picos for more lights, and if I'm only controlling one bulb, doing it in Button Controller isn't too bad, but I'm running into complexities in multi-bulb rooms/setups (e.g., I only want to dim/brighten bulbs that are already on, not all the ones I've selected regardless). It's also cumbersome to set up the same devices on a lot of buttons where I really want to control the same devices with each button, just with different actions.

I'm thinking of creating a "Dimmer Button Controller" app that might:

  • let you choose a button device (I'm thinking about this with a Pico "5-button"/3BRL device in mind, but really anything should work); and
  • let you choose bulbs/dimmers/switches to control with this device; and
  • be able to specify for each button press or hold:
    • whether all or select specified bulbs should be turned on/off (or not changed at all) and, optionally, to what level, color temperature, color, etc. (like you can with the Hue Dimmer by choosing a scene--and maybe I could make this a Hubitat scene you could choose instead, though that feature is so new I'm not sure how people are using it yet); or
    • whether to dim/brighten selected bulbs, changing (maybe optionally?) only those that are already on (exception: start brightening all if that action is chosen and none are on)
      • would be nice to support the "start/stop level change" feature here if using the "fast Pico" ("pressed/released" rather than "pressed/held") driver--e.g., start changing when button pressed and stop when released--but Hue bulbs brought into Hubitat via the Hue Bridge, which all of mine are, don't appear to support this in their driver, so I wouldn't be able to test that (nor would I have an interest in developing something I can't use :slight_smile: )
  • default to whatever Button Controller does when you specify the fade/transition time as 0 unless otherwise specified (BC's default is apparently greater than 0, and the press/hold nature of the non-fast Pico driver already makes this notably slower than a Hue Dimmer; even "0" isn't truly 0 and is probably the Hue default of half a second or so, but that is what I'm used to with Hue and fine with me); and
  • if this would work reliably on Hubitat and I have the time, try to emulate the "one through five presses" feature on the Hue Dimmer (can only imagine this working on the Fast Pico driver) for at least button 1 (like the Hue DImmer), though button 3 on the 5-button would also make sense: have some sort of timer in the app that notes the time since the last press of this particular button and, if it happens within a specified time period since the last press and no other buttons were pressed in between (a trick I use on the Hue dimmer to get back to my first scene is press Off then On), then rotate through "actions 1 through 5" or however many are configured.

This makes it sound complicated, but basically I'd like an easy way to emulate the functionality the Hue dimmer provides when paired directly to Hue. Thought I'd throw out my ideas before I get too far into this in case anyone who'd be interested has any suggestions (e.g., would choosing a Hubitat scene be useful?). Or if anyone has already started on this or knows some trick in Button Controller, ABC, or RM that I don't (again: seems overly complicated to repeat portions of the same configuration--e.g., bulb/dimmer selection--for each button in Button Controller when it's really going to be the same for all of them), let me know. :slight_smile:

Here is what I came up with to somewhat mimic the Hue Dimmer switch. I have my Hue bulbs all programmed so at different times of day the color temperature is changed, so pressing button 1 first just turns the light on. If I don't want the color temperature that is set, then I can rotate through 5 color temperatures by pressing button 1 repeatedly.

I implemented dim/brighten with single presses in increments of 20...would love to see somebody do the dim/brighten with held/released!

Any ideas for button 3? I was thinking maybe to toggle all lights on/off. Nothing implemented yet.

This is a parent/child app, so install both pieces of app code, then install the parent app and set the children from there. There will be one child per pico remote.

Please feel free to take and modify as you wish!

/*
 *  Pico color temp bulb controller
 */
definition(name: "Pico Color Temp Bulb Controller",
           namespace: "hubitat",
           author: "dagrider",
           description: "Cycle through bulb color temps with button 1, off with button 5, dim with buttons 2 and 4 (parent)",
           category: "Green Living",
           singleInstance: true,
           iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch.png",
           iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch@2x.png")

preferences {
    page(name: "mainPage", title: "Pico Color Temp Bulb Controller", install: true, uninstall: true, submitOnChange: true) {
        section {
            app(name: "picoInstance", appName: "Pico Color Temp Bulb Controller Instance", namespace: "hubitat", title: "Create Pico Controller", multiple: true)
        }
    }
}

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

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

def initialize() {
    log.debug "initialize"
    log.debug "there are ${childApps.size()} child smartapps"
    childApps.each {child ->
        log.debug "child app: ${child.label}"
    }
}

/*
 *  Pico color temp bulb controller instance
 *  Button 1 presses:
 *  1: turn bulb(s) on (can have the bulb programmed to set color temp depending on time of day, when it is turned on)
 *  2: set bulb(s) to Nightlight 
 *  3: set bulb(s) to Relax
 *  4: set bulb(s) to Read
 *  5: set bulb(s) to Concentrate
 *  6: set bulb(s) to Energize
 *  7: back to Nightlight, etc
 */
definition(name: "Pico Color Temp Bulb Controller Instance",
           namespace: "hubitat",
           author: "dagrider",
           description: "Cycle through bulb color temps with button 1, off with button 5, dim with buttons 2 and 4 (instance)",
           category: "Green Living",
           parent: "hubitat:Pico Color Temp Bulb Controller",
           iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch.png",
           iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch@2x.png")

preferences {
    section {
        input "thePico", "capability.pushableButton", title: "Choose Pico Remote"
        input "theBulb", "capability.colorTemperature", title: "Choose bulb/group to control"
    }
}

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

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

def initialize() {
    log.debug "initialize"
    subscribe(thePico, "pushed", pushedHandler)
    subscribe(theBulb, "switch", switchHandler)
    state.pressNum = 0
}

def pushedHandler(evt) {
    switch(evt.value) { 
        case "1": 
            log.debug "button 1 pushed"
        
            if (state.pressNum == 0) {
                    log.debug "pressNum is 0, On"
                    bulbOn()
                    sendEvent(name: "on", value: "pressNum: $state.pressNum", descriptionText: "Turn bulb on")
                    state.pressNum = 1
            } else if (state.pressNum == 1) {
                    log.debug "pressNum is 1, Nightlight"
                    theBulb.setLevel(1)
                    theBulb.setColorTemperature(2237)
                    sendEvent(name: "on", value: "pressNum: $state.pressNum", descriptionText: "Set bulb to Nightlight")
                    state.pressNum = 2
            } else if (state.pressNum == 2) {
                    log.debug "pressNum is 2, Relax"
                    theBulb.setColorTemperature(2237)
                    theBulb.setLevel(57)
                    sendEvent(name: "on", value: "pressNum: $state.pressNum", descriptionText: "Set bulb to Relax")
                    state.pressNum = 3
            } else if (state.pressNum == 3) {
                    log.debug "pressNum is 3, Read"
                    theBulb.setColorTemperature(2890)
                    theBulb.setLevel(100)
                    sendEvent(name: "on", value: "pressNum: $state.pressNum", descriptionText: "Set bulb to Read")
                    state.pressNum = 4
            } else if (state.pressNum == 4) {
                    log.debug "pressNum is 4, Concentrate"
                    theBulb.setColorTemperature(4292)
                    theBulb.setLevel(100)
                    sendEvent(name: "on", value: "pressNum: $state.pressNum", descriptionText: "Set bulb to Concentrate")
                    state.pressNum = 5
            } else if (state.pressNum == 5) {
                    log.debug "pressNum is 5, Energize"
                    theBulb.setColorTemperature(6536)
                    theBulb.setLevel(100)
                    sendEvent(name: "on", value: "pressNum: $state.pressNum", descriptionText: "Set bulb to Energize")
                    state.pressNum = 1
            }
        
            break;
        case "2": 
            log.debug "button 2 pushed"
        
            if (theBulb.currentValue("switch") == "off") {
                bulbOn()
                sendEvent(name: "brighten", value: "", descriptionText: "Brighten bulb to on")
            } else {
                def lvl = getLevel(1)
                log.debug "brighten to level $lvl"
                theBulb.setLevel(lvl)
                sendEvent(name: "brighten", value: "level: $lvl", descriptionText: "Brighten bulb to $lvl")
            }
        
            break;
        case "3": 
            // todo: center button
            break;
        case "4": 
            log.debug "button 4 pushed"
            
            if (theBulb.currentValue("switch") != "off") {
                def lvl = getLevel(0)
                log.debug "dim to level $lvl"
                
                if (lvl == 0) {
                    bulbOff()
                    sendEvent(name: "dim", value: "", descriptionText: "Dim bulb to off")
                } else {
                    theBulb.setLevel(lvl)
                    sendEvent(name: "dim", value: "level: $lvl", descriptionText: "Dim bulb to $lvl")
                }
            } 
        
            break;
        case "5": 
            log.debug "button 5 pushed"
            bulbOff()
            sendEvent(name: "off", value: "pressNum: $state.pressNum", descriptionText: "Turn bulb off")
            break;
        default:
            return
    }
}

private bulbOn() {
    theBulb.on()
    theBulb.refresh()
}

private bulbOff() {
    theBulb.off()
    theBulb.refresh()
    state.pressNum = 0
}

def switchHandler(evt) {
    switch(evt.value) { 
        case "on": 
            state.pressNum = 1
            break
        case "off":
            state.pressNum = 0
            break
    }
}

private int getLevel(typ) {
    def lvl = theBulb.currentValue("level").toInteger()
    log.debug "current level: $lvl"
    
    switch (lvl) {
        case 0..10: 
            lvl = 0
            break
        case 11..30:
            lvl = 20
            break
        case 31..50:
            lvl = 40
            break
        case 51..70:
            lvl = 60
            break
        case 71..90:
            lvl = 80
            break
        default:
            lvl = 100
            break
    }
    
    log.debug "adjusted level: $lvl"
    
    if (typ == 1) lvl = lvl + 20
    else lvl = lvl - 20
        
    if (lvl > 100) lvl = 100
    else if (lvl <= 0) lvl = 0
    
    log.debug "new level: $lvl"
    return lvl
}
1 Like

Alright, so it took me a while, but I've been working on an app that allows the remote to be configured to mimic the Hue Dimmer more easily than Button Controller or Advanced Button Controller, where you have the choose the lights for each button, by allowing you to choose all the lights at once (sort of like how Hue lets you choose a room for the remote) and then just configure each button to do what you want: turn on (and optionally set level, color temperature, and/or color for each--sort of like manually putting in scene information), dim up, dim down, or turn off. The dimming actions will only affect lights that are currently on, which I don't think BC or ABC do.

I'm hosting it on GitHub here. It's a parent/child app, so you'll need to add the code for both and then install the parent:

I haven't tested it much, but it works well so far for me. I'm not a huge fan of how the UI is laid out, but it's tough to write these for an arbitrarily large number of devices. If we're able to make more tabular layouts (like some new stock apps do), I don't know how, but think that would help.

I made it flexible enough to work with any button device (only supports "press," which should cover them all). My suggested configuration for a 5-button Pico (model 4BRL) would be:

  • Button 1: Turn on
    • Presses 1-5: whatever you want, possibly press 1 just turning on and the rest setting specific "scene"-type settings (manually; see above). You do not need to configure more than 1 press if you do not want to, and if you just want it to turn on to the last "on" values, you don't even need to configure it at all besides setting "Turn on" for button 1.
  • Button 2: Brighten/Dim Up
  • Button 3: Why not make it like button 1, then you'll have the ability to set up to ten "scenes" with one remote!
  • Button 4: Dim (Dim Down)
  • Button 5: Turn off

The code is, again, a little rough around the edges, but I think this is what I want. The code from denise.grider above is definitely a lot easier to use if you just want to cycle through a set order of predefined settings like Hue "scenes"/recipes, but I wanted to do something a bit different for each room so tried to make this customizable--so customizable it's probably a bit difficult to set up (if I can figure out a way to make it automatically do sensible things for specific button devices, I'll try--e.g., on a 5-button Pico I can't imagine anyone would want to do anything drastically different from teh above).

If anyone has any use for this, feel free to try it out. I'll keep polishing it up and eventually put it in the code-share category when I'm less embarrassed about it. :slight_smile:

Download the Hubitat app