Virtual Dimmer and Dim With Me

Created a new SmartThings “Virtual Dimmer” and a “Dim With Me” app that subscribes to it. Now I have many dimmers follow in unison. One virtual dimmer for each room group. My Tasker Gentle Wake-up task drives now only the virtual dimmer and the subscribed lights follow. Also, I can set the virtual dimmer level with Tasker and Autovoice. No lag or pause between each light getting a command. It works faster/better than the actual wall dimmer switches.

This stuff is too cool!

5 Likes

Here’s some video to show it working. let me know what you think.

4 Likes

bad. ass.

Nicely done dude.

@wackware - very cool!

Any chance you would share your device code?

How do I go about adding this Smartapp?

I’d like to add this app too, please. Where can I find it?

Try this thread for updated code…

1 Like

Hi,
I am trying to use dim with me with a virtual switch… But nothing happens when I switch on or off or dim the virtual dimmer. I added a device in ide of type dimmer switch. Is that correct? How can I debug or see what is causing it not to work?

Thank you.

If you’ve been trying this over the last few hours it will be hit and miss, ST’s a bit backwards at the moment.

Yup… Will try tomorrow :slight_smile: thanks…

No luck today either. Anyone has it working? I know it worked before…

No. You need a “Virtual Dimmer Switch” as the device type. If that isn’t in the list of available Device Types, then you will have to get the Device Type code and install the Device Type in the IDE, and Publish [For me], then create the Virtual Dimmer.

1 Like

Thanks. I doubted that but I do not have virtual dimmer switch in my list. Will search for code and add the new device type and try.

Thanks.

I think it’s called “Virtual Dimmer”.

Not in my list of devices. Can you please send me the code for that device?

Here you go:

metadata {
        definition (name: "Virtual Dimmer", namespace: "", author: "smartthings") {
        capability "Switch"
        capability "Refresh"
        capability "Switch Level"
    }

	// simulator metadata
	simulator {
	}

	// UI tile definitions
	tiles {
		standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "off", label: 'Off', action: "switch.on", icon: "st.Kids.kid10", backgroundColor: "#ffffff", nextState: "on"
			state "on", label: 'On', action: "switch.off", icon: "st.Kids.kid10", backgroundColor: "#79b821", nextState: "off"
		}
		standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
			state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
		}        
        controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, backgroundColor:"#ffe71e") {
            state "level", action:"switch level.setLevel"
        }
        valueTile("lValue", "device.level", inactiveLabel: true, height:1, width:1, decoration: "flat") {
            state "levelValue", label:'${currentValue}%', unit:"", backgroundColor: "#53a7c0"
        }

		main(["button"])
		details(["button", "refresh","levelSliderControl","lValue"])
	}
}

def parse(String description) {
}

def on() {
	sendEvent(name: "switch", value: "on")
    log.info "Dimmer On"
}

def off() {
	sendEvent(name: "switch", value: "off")
    log.info "Dimmer Off"
}

def setLevel(val){
    log.info "setLevel $val"
    
    // make sure we don't drive switches past allowed values (command will hang device waiting for it to
    // execute. Never commes back)
    if (val < 0){
    	val = 0
    }
    
    if( val > 100){
    	val = 100
    }
    
    if (val == 0){ // I liked that 0 = off
    	sendEvent(name:"level",value:val)
    	off()
    }
    else
    {
    	on()
    	sendEvent(name:"level",value:val)
    	sendEvent(name:"switch.setLevel",value:val) // had to add this to work if apps subscribed to
                                                    // setLevel event. "Dim With Me" was one.
    }
}

def refresh() {
    log.info "refresh"
}
1 Like

Thank you.

Gives me an error when I try to save:

physicalgraph.exception.ValidationException: Validation error

Sorry, bug is it needs an author. Just put your name in there, and it should work.

Thanks. It works now :slight_smile: