AspenCo’s code fixed my problem! awesome. now if i can only integrate Ajma’s code to update the slave’s state it’ll be perfect…
ok, i merged AspenCO’s and Ajma’s code together, so now you have the slave’s state updating and dimming following the master [tried it with hue bulbs and jasco wall dimmers and it works.] can someone please double check the code to make sure i did it efficiently?
/**
- dim-with-me.app.groovy
- Dim With Me
- Author: todd@wackford.net
- Date: 2013-11-12
/
/*- App Name: Dim With Me
- 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 muchbut some devices only sending level event and not setLevel.
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”,
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 {
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 dimming level…”) {
input “slaves”, “capability.switchLevel”,
multiple: true,
title: “Slave Dimmer Switch(es)…”,
required: true
}
}
def installed()
{
subscribe(masters, “switch.on”, switchOnHandler)
subscribe(masters, “switch.off”, switchOffHandler)
subscribe(masters, “switch.setLevel”, switchSetLevelHandler)
subscribe(masters, “switch”, switchSetLevelHandler)
subscribe(masters, “level”, switchSetLevelHandler)
subscribe(slaves2, “switch.on”, slavesOnHandler)
subscribe(slaves2, “switch.off”, slavesOffHandler)
log.info “installed to all of switches events”
}
def updated()
{
unsubscribe()
subscribe(masters, “switch.on”, switchOnHandler)
subscribe(masters, “switch.off”, switchOffHandler)
subscribe(masters, “switch.setLevel”, switchSetLevelHandler)
subscribe(masters, “switch”, switchSetLevelHandler)
subscribe(masters, “level”, switchSetLevelHandler)
subscribe(slaves2, “switch.on”, slavesOnHandler)
subscribe(slaves2, “switch.off”, slavesOffHandler)
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: ${masters.latestValue(“level”)}”
slaves?.setLevel(masters.latestValue(“level”))
}
def switchOffHandler(evt) {
log.info “switchoffHandler Event: ${evt.value}”
slaves?.off()
slaves2?.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()
}
def slavesOnHandler(evt) {
def allOn = true
for(slave in slaves2) {
if(slave.currentValue(“switch”) == “off”) {
allOn = false
last
}
}
if(allOn && masters.currentValue(“switch”) == “off”) {
masters.on()
}
}
def slavesOffHandler(evt) {
def allOff = true
for(slave in slaves2) {
if(slave.currentValue(“switch”) == “on”) {
allOff = false
last
}
}
if(allOff && masters.currentValue(“switch”) == “on”) {
masters.off()
}
}
Some delay, but nice App 
please dont use the code i posted, it’s buggy and the lights sometimes turn on/off randomly after you turn lights off. someone will need to debug the code.
First off, thanks for providing this. I can’t imagine why this isn’t a built in feature. I am having an issue, however, and I was hoping for a little help. What I want from this is to be able to use a wall dimmer, likely a GE, to control my LIFX bulbs so that I can keep them powered and always have access to them. I don’t currently have an actual dimmer, so to test the app I used one of my GE fan controllers as a dimmer, since they show as dimmers in ST. The code from Todd was able to turn on/of a light following the fan dimmer, but not adjust dimming. So on a whim, and even though he said not to, I tried mrsmartypants version. With his, the lights follow the fan speed, but I sometimes get odd light surges during transition. Even though the fan technically only has 3 speeds, it seems that the bulbs will follow the indicated percentage I select with the slider. Is this an effect of my setup? Did I do something wrong creating the app? Unfortunately, I don’t know the first thing about writing stuff for ST, yet.
Thanks for providing this update. I am trying to control a Hue bulb dimming using a HomeSeer WD100+. This almost works, but not quite. When dimming using the WD100 as master, the Hue simply turns off. Thoughts on how to fix?
Where can I find the latest ‘Dim with me’ code? Is there an authoritative version in github? In general, how do I know which version of a SmartApp is the latest? Posting code to a community form doesn’t seem like a very good way to manage source code…
Sorry newbie questions…
Anyone have an update to this? Functionality is so close. Just a little buggy. Would love to see this ironed out. Sorely needed functionality in ST. Any thoughts appreciated.
ASpenCO,
Your changes worked for me on my GE Smart Dimmer (in-wall), which I use to control two SYLVANIA LIGHTIFY bulbs that are paired directly with the SmartThings hub. (Without this modified script I had on/off working fine through the ST app, but lacked Dimmer support.)
I have GE Smart Dimmer Z-Wave, In-Wall, 12724 and found I couldn’t use SmartThings in-app options to control the dimmer, on/off worked fine but that’s it.
The dimmer is recognized as an on/off switch by SmartThings but not fully as a dimmer. Your script changes resolved that for me. I’m still unclear if this is a support issue on the SmartThings side or the GE side.
For reference:
GE Dimmer https://www.amazon.com/gp/product/B006LQFHN2/ref=oh_aui_search_detailpage?ie=UTF8&psc=1
Lightify Bulbs https://www.amazon.com/gp/product/B0197840KQ/ref=oh_aui_search_detailpage?ie=UTF8&psc=1
edit: updated for clarity on On/Off vs dimmer support
Is Dim With Me still in use? I’m trying to use it on my Philips bulbs with no success.
I would suggest looking at Trend Setter instead. It may do what you want and works quite well.
Thanks @kes601. Seems like there’s lots of suggestions for Dim With Me on the forums, but they’re mostly dated. I’ll give Trend Setter a shot.
Mirror has been added to the SmartLighting App. Give that a shot.