Virtual Dimmer and Dim With Me

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:

Just want to say thanks - I use this to control a single fixture with 5 smart bulbs in it and it works great!

Trying to get this to work with Cree Connected light bulbs and the dimming portion does not work yet the bulbs work perfectly with ST including dimming and so on. Any advise or things to try? I’ve tried a variety of options in the program but it doesn’t seem to work at all.

Try this app, it does the same sort of thing:

You don’t have to use the motion section, if that doesn’t apply. Make your virtual dimmer be the master.

1 Like