Double Tab(p)? Dim


(Barry Murphy) #1

I found example code for Double Tab in the SmartApps area; the code is a little more technical than some of the previous examples I’ve worked with so hoping someone can help.

I’d love to be able to double tap a light switch and for the lights to then dim to a certain level.
If anyone that is at the level of the ‘Double Tab’ smartapp that would like to help :smile:
I simply want to add the following code so I can set the dim level for the ‘switches’ attribute.

Currently this exists:

section("Turn on or off all of these switches as well") {
    input "switches", "capability.switch", multiple: true, required: false
}

All I want to add is the following and the driver for ‘switches’ to set the dim level.

section (“Set Dim Levels”) {
input “DimLevelStr”, “enum”, title: “Dimmed Level %”, required: true,
options: [“20”,“30”,“40”,“50”,“60”,“70”,“80”,“90”,“100”], defaultValue: “30”
}

Any help would be greatly appreciated.

Many thanks
Barry


(Brice; SmartRulesApp.com) #2

This is untested code, but you should just need something like this in the preferences:

section("Dim all of these switches as well") {
	input "dimmers", "capability.switchLevel", multiple: true, required: false
}

Then something like this in switchHandler where the current on/off code is:

if (evt.value == "on" && lastTwoStatesWere("on", recentStates, evt)) {
    log.debug "detected two taps, dim lights"
    dimmers*.setLevel(DimLevelStr)
}