Best SmartApp for Complex "follow me" Dimming Setups?


#1

Continuing the discussion from GE/Jasco Dimmers not able to dim?:

Honestly, I’m not the best person to ask about lighting scenes, I’m more just an on/off kind of person. I’m interested in the input devices, but not too much in the outcomes, if that makes sense. At least as far as lighting.

Starting a new topic for you to get it out of the device category…

Anyway, there are a bunch of people who are seriously into various lighting scenes and have written a bunch of different apps for different setups, so one of them should be able to help. Just off the top of my head (I’m sure there are more people): @tslagle13 , @infofiend , @Mike_Maxwell , @Sticks18 , @baldeagle072 , @wackware , @smart , @bravenel ,and @tgauchat all have complex lighting set up code and can likely make recommendations.

I know there’s code out there that captures specific settings, I just don’t know if there’s an existing “follow me” app with the kind of relationships you were looking for.


GE/Jasco Dimmers not able to dim?
#2

Also adding @JoeC, @obycode in case the rules engines do this. And @geko although I think he’s been busy with other stuff lately.


(Tim Slagle) #3

Can you describe exactly what yoire looking for?:slight_smile:


(Tasmin) #4

A part of my house is from the 40s and has no ground or neutral wiring. This includes half the living room. Here and in a couple other areas, I’d like to supplement my Cree floods on a smart dimmer with smart bulbs - GE Link floods.

Primarily I’d like the one smart switch to act as a switch for alll. When I raise or lower the brightness on the wall smart switch including turning on and off, I’d like all the bulbs to respond.

Secondarily due to a situation in my bathroom where I have an integrated LED dimmable fixture over the mirror, I’d like to virtually ‘link’ it to a smart flood over my shower through the mirror’s smart dimmer wall switch. They are different lumens so I’d imagine it would need a ratio situation because if they were both at 50% they would likely look very different. But I understand this is much more complicated.

What do you think?


(Tim Slagle) #5

The first one is simple. Let me sleep on the second scenario


(Scott G) #6

The only caveat with both is that when you make changes at the physical switch, there may be a longer delay since very few smart switches report instantly. ST has to poll the switch, so just a little more delay than if you make the change via the app.

For the 2nd one, we could easily do an offset like light A is the master and light B follows at 10% higher. It might make more sense to have the offset be a ratio or vary across the dim range. It might be different for every lighting situation, which makes it tougher. Can you pick maybe 4-5 different dim levels and provide the levels for the two lights to your liking? Then we can figure out the type of offset and build that in.


(Tony - SmartThings Unpublished Contributor ) #7

I have that functionality in FLEXi lighting. I basically identify one light as the “master” light, and then have the option of identifying additional lights as either being a “slave” light or a “free” light. Any “slave” light received the level (and in case of Hue lights, color) settings of the “master” light. To accomplish this, I needed to add some custom attributes / methods to the devices that I use within the system. Check out FLEXi Lighting - a flexible system for lighting scenes (Hues, dimmers, and switches) – specifically the code for the FLEXi Scenes and Flexi Triggers Apps, and the code for the FLEXiHue device type.


(Tasmin) #8

I’ll go home tonight and map the exact levels I’m looking for as an example.

As for the delay that doesn’t worry me too much. Half the time I set the lighting directly through HHAs and timing, motion, its just the other half where my husband or kids flip the switch or in the bathroom where I only manually turn it on/off when needed. Last thing I need first thing after wakeup is to fumble around with an app so I can take a shower to wake up in the morning. :slight_smile:


(Tasmin) #9

Can you specify any relationships, like slave always follows master but 10% dimmer?


(Tasmin) #10

In both of my person scenarios, the answer is that light B (smart bulb) should be 10% dimmer (less bright) than light A (the smart switch)


(Tony - SmartThings Unpublished Contributor ) #11

Not in current setup, but that’s not a bad idea. I’ll update the scenes app and get back to you.


(Scott G) #12

Here’s an app with the option to have up to two brighter and two dimmer slave groups as well as the traditional options. (I couldn’t get the ratio code to work, probably because of variable type conflicts; but the live logging wasn’t working for me to debug)

I tested it with only a couple of bulbs, but it seemed to work well including the sanity checks for when the offset would exceed the min/max dim levels.

Let me know if it works for your scenario. I know the Dim with Me app always worked better with virtual masters, but hopefully it correctly subscribes to the wall switch for you.

/**
 *  Dim With Me - plus offset
 *
 *  Original Author: todd@wackford.net
 *  Date: 2013-11-12
 */ 
/**
 *  App Name:   Dim With Me plus Offset
 *
 *  Author:     Todd Wackford
 *        twack@wackware.net
 *  Date:     2013-11-12
 *  Version:     0.2
 *  
 *  Use this program with a virtual dimmer as the master for best results.
 *
 *  This app lets the user select from a list of dimmers to act as a triggering
 *  master for other dimmers or regular switches. Regular switches come on
 *  anytime the master dimmer is on or dimmer level is set to more than 0%.
 *  of the master dimmer.
 *
******************************************************************************
 *                                Changes
 ******************************************************************************
 *
 *  Change 1:    2014-10-22 (wackford)
 *        Fixed bug in setlevelwhen on/off was coming in
 *
 *  Change 2:    2014-11-01 (wackford)
 *        added subscription to switch.level event. Shouldn't change much
 *        but some devices only sending level event and not setLevel.
 *
 *  Change 3:   2015-05-05 (sticks18)
 *              added ability to offset slave dimmers in case different lights
 *              dim differently or have varying lumen output.
 *
 ******************************************************************************
                
  Other Info:    Special thanks to Danny Kleinman at ST for helping me get the
                state stuff figured out. The Android state filtering had me 
                stumped.
 *
 ******************************************************************************
 */


// Automatically generated. Make future change here.
definition(
    name: "Dim With Me plus Offset",
    namespace: "wackware",
    author: "todd@wackford.net",
    description: "Follows the dimmer level of another dimmer",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png"
)

preferences {
    page(name: "selectMaster", title: "Select Basic Devices", install: true, uninstall: true) {
    
        section("When this...") { 
            input "masters", "capability.switchLevel", 
                multiple: false, 
                title: "Master Dimmer Switch...", 
                required: true
        }

        section("Then these will follow with on/off...") {
            input "slaves2", "capability.switch", 
                multiple: true, 
                title: "Slave On/Off Switch(es)...", 
                required: false
        }
    
        section("And these will follow with the same dimming level...") {
            input "slaves", "capability.switchLevel", 
                multiple: true, 
                title: "Slave Dimmer Switch(es)...", 
                required: false
        }
    
        section("Slaves with offset...") {
            href "addOffset", title:"Additive Offset (Slave = Master Level + Offset)"
            href "minusOffset", title: "Negative Offset (Slave = Master Level - Offset)"
//            href "ratioOffset", title: "Ratio Offset (Slave X% of Master Level)"
        }
        
        section("Name and Mode...") {
            label title: "Assign a name", required: false
            mode title: "Set for specific mode(s)", required: false
        }
    }
        
    page(name: "addOffset", title: "addOffset")
    page(name: "minusOffset", title: "minusOffset")
//    page(name: "ratioOffset", title: "ratioOffset")
    
}

def addOffset() {
    dynamicPage(name: "addOffset", title: "Select Additive Offset Slave Dimmers...", install:false, uninstall: false) {
        section("Additive Offset Group 1") {
            input "slavesAdd1", "capability.switchLevel", title: "Slave Dimmers...", multiple: true, required: false
            input "levelAdd1", "number", title: "Level Offset (number to be added to master level)", required: false
        
        }
        
        section("Additive Offset Group 2") {
            input "slavesAdd2", "capability.switchLevel", title: "Slave Dimmers...", multiple: true, required: false
            input "levelAdd2", "number", title: "Level Offset (number to be added to master level)", required: false
        
        }
        
    }
}

def minusOffset() {
    dynamicPage(name: "minusOffset", title: "Select Negative Offset Slave Dimmers...", install:false, uninstall: false) {
        section("Negative Offset Group 1") {
            input "slavesMin1", "capability.switchLevel", title: "Slave Dimmers...", multiple: true, required: false
            input "levelMin1", "number", title: "Level Offset (number to be subtracted from master level)", required: false
        
        }
        
        section("Negative Offset Group 2") {
            input "slavesMin2", "capability.switchLevel", title: "Slave Dimmers...", multiple: true, required: false
            input "levelMin2", "number", title: "Level Offset (number to be subtracted from master level)", required: false
        
        }
        
    }
}

/* The math for the ratio isn't working
def ratioOffset() {
    dynamicPage(name: "ratioOffset", title: "Select Ratio Offset Slave Dimmers...", install:false, uninstall: false) {
        section("Ratio Offset Group 1") {
            input "slavesRatio1", "capability.switchLevel", title: "Slave Dimmers...", multiple: true, required: false
            input "levelRatio1", "number", title: "X% of Master Level (ie: 10 = 0.10 * Master Level, 110 = 1.10 * Master Level)", required: false
        
        }
        
        section("Ratio Offset Group 2") {
            input "slavesRatio2", "capability.switchLevel", title: "Slave Dimmers...", multiple: true, required: false
            input "levelRatio2", "number", title: "X% of Master Level (ie: 10 = 0.10 * Master Level, 110 = 1.10 * Master Level)", required: false
        
        }
        
    }
}
*/


def installed()
{
    subscribe(masters, "switch.on", switchOnHandler)
    subscribe(masters, "switch.off", switchOffHandler)
    subscribe(masters, "switch.setLevel", switchSetLevelHandler)
    subscribe(masters, "switch", switchSetLevelHandler)
}

def updated()
{
    unsubscribe()
    subscribe(masters, "switch.on", switchOnHandler)
    subscribe(masters, "switch.off", switchOffHandler)
    subscribe(masters, "switch.setLevel", switchSetLevelHandler)
    subscribe(masters, "switch", switchSetLevelHandler)
    log.info "subscribed to all of switches events"
}

def switchSetLevelHandler(evt)
{    
    
    if ((evt.value == "on") || (evt.value == "off" ))
        return
    def level = evt.value.toFloat()
    level = level.toInteger()
    log.info "switchSetLevelHandler Event: ${level}"
    
    if (levelAdd1) {
        
        def lvlAdd1 = level + levelAdd1
        lvlAdd1 = lvlAdd1.toInteger()
        if (lvlAdd1 > 100) {lvlAdd1 = 100}
        if ((lvlAdd1 < 1) && (level > 0)) {lvlAdd1 = 1}
        log.info "switchSetLevelHandler Add 1 Offset Event: ${lvlAdd1}"
        slavesAdd1?.setLevel(lvlAdd1)
        
    }
    
    if (levelAdd2) {
        
        def lvlAdd2 = level + levelAdd2
        lvlAdd2 = lvlAdd2.toInteger()
        if (lvlAdd2 > 100) {lvlAdd2 = 100}
        if ((lvlAdd2 < 1) && (level > 0)) {lvlAdd2 = 1}
        log.info "switchSetLevelHandler Add 2 Offset Event: ${lvlAdd2}"
        slavesAdd2?.setLevel(lvlAdd2)
        
    }
    
    if (levelMin1) {
        
        def lvlMin1 = level - levelMin1
        lvlMin1 = lvlMin1.toInteger()
        if (lvlMin1 > 100) {lvlMin1 = 100}
        if ((lvlMin1 < 1) && (level > 0)) {lvlMin1 = 1}
        log.info "switchSetLevelHandler Minus 1 Offset Event: ${lvlMin1}"
        slavesMin1?.setLevel(lvlMin1)
        
    }
    
    if (levelMin2) {
        
        def lvlMin2 = level - levelMin2
        lvlMin2 = lvlMin2.toInteger()
        if (lvlMin2 > 100) {lvlMin2 = 100}
        if ((lvlMin2 < 1) && (level > 0)) {lvlMin2 = 1}
        log.info "switchSetLevelHandler Minus 2 Offset Event: ${lvlMin2}"
        slavesMin2?.setLevel(lvlMin2)
        
    }
    
/*    
    if (levelRatio1) {
        
        def lvlRatio1 = math.Round((levelRatio1/100)*level)
        lvlRatio1 = lvlRatio1.toInteger()
        if (lvlRatio1 > 100) {lvlRatio1 = 100}
        if ((lvlRatio1 < 1) && (level > 0)) {lvlRatio1 = 1}
        log.info "switchSetLevelHandler Ratio 1 Offset Event: ${lvlRatio1}"
        slavesRatio1?.setLevel(lvlRatio1)
        
    }
    
    if (levelRatio2) {
        
        def lvlRatio2 = math.Round((levelRatio2/100)*level)
        lvlRatio2 = lvlRatio2.toInteger()
        if (lvlRatio2 > 100) {lvlRatio2 = 100}
        if ((lvlRatio2 < 1) && (level > 0)) {lvlRatio2 = 1}
        log.info "switchSetLevelHandler Ratio 2 Offset Event: ${lvlRatio2}"
        slavesRatio2?.setLevel(lvlRatio2)
        
    }
*/

    slaves?.setLevel(level)
}

def switchOffHandler(evt) {
    log.info "switchoffHandler Event: ${evt.value}"
    slaves?.off()
    slaves2?.off()
    slavesAdd1?.off()
    slavesAdd2?.off()
    slavesMin1?.off()
    slavesMin2?.off()
    slavesRatio1?.off()
    slavesRatio2?.off()
}

def switchOnHandler(evt) {
    log.info "switchOnHandler Event: ${evt.value}"
    def dimmerValue = masters.latestValue("level") //can be turned on by setting the level
    slaves?.on()
    slaves2?.on()
    slavesAdd1?.on()
    slavesAdd2?.on()
    slavesMin1?.on()
    slavesMin2?.on()
    slavesRatio1?.on()
    slavesRatio2?.on()
}

(Tasmin) #13

I added the Smart app and the set up and options are exactly what I want. However its only functioning as turning on/off despite the fact I only put the slaves listed in the - offset section. As a trial, I moved them to the dim with me section instead, and they aren’t doing that either. just reporting on/off at 100%.

However Im not at home and cant actually see if they are dimming, only looking at the Thing tile reporting % dimming. Its possible that isn’t refreshing even though I pushed the refresh button.

Will try again tonight when Im looking at them


(Tony - SmartThings Unpublished Contributor ) #14

I’ll be uploading tonight revised versions of the smartapp-created code and hue device code. It will include the percentage functionality. Also removed some bugs.

1 question - you said that you added “the smartapp” - did you mean “smartapps”? And did you also:

-add the code for the hue bridge and hue bulbs?
-delete your existing hue devices, and delete the standard hue connect app
-re-add the hues via the Flexihue (hue connect) smartapp?


(Tony - SmartThings Unpublished Contributor ) #15

Version 1.1 of the smart apps and Hue Bulb device code are now available - you can now specify ( on a per scene basis) that any Slave Hues / Dimmers should have a level equal to X percent of the level of the Master Hue.

FLEXi Lighting - a flexible system for lighting scenes (Hues, dimmers, and switches)


(Scott G) #16

I found the issue and fixed it. Add this line in the installed() and updated() sections after the subscription for “switch”. This will correctly pick up the level changes for the wall dimmer. Sorry about that.

subscribe(masters, “level”, switchSetLevelHandler)


(Tasmin) #17

@infofiend “Smart app” was just an autocorrect issue. My bulbs have always been GE Link, not hue, so I don’t think your code is what I’m looking for

@Sticks18 great thanks. I’ll try it again shortly. The delay on the slaves is actually handy when turning it off, because I get a few extra seconds of light to lead me out of a dark room.


(Tasmin) #18

@Sticks18 PERFECT thanks!! I love that there are two sections for offsets, I’m going to set up my living room to have gradually dimming lighting into the dining.


(Scott G) #19

You’re welcome!! Glad it’s working for you!!

I hoped 2 sections would be enough. It’s easy to add more, but didn’t want the app to be unwieldy. Ideally I’d like for the user to add as many as they want, but I’m not that fancy…


(Tasmin) #20

Ok, ive got another request if its not too much trouble…

Background: So my situation is that my dining room functions as a family space and is used for different things throughout the day. I always want my dining table lights (slave) to come on when the overhead lights (master) come on, but sometimes later I just want the dining table lights to stay on into dinner but turn off the overheads at the switch (which currently turns them all off).

Request: Is it possible to have slaves follow masters in “on” and dimming capabilities, but not in “off” setting?

This is clearly in the ‘nice to have’ capability, but it would be very nice to have. I’m trying to think of how that would be structured. Maybe the slave ignores any commands under 10% dimming?