Hi, I’m new to SmartThings and almost done configuring my devices & scenarios. I use Virtual Switches to trigger Lighting scenes (eg. Late Afternoon, Evening, Late Evening). Use Virtual Switches as well to change stations on Sonos. It works as expected however, the “Device Type” code is currently written as a switch (with on & off state). Since lighting scenes do not neccessarily have to be switched off, I would like to turn this into a push button which does not visually change status.
The code I used to create the new Device Type is from Juan Risso:
metadata {
definition (name: "Virtual Switch", namespace: "smartthings", author: "Juan Risso") {
capability "Switch"
capability "Refresh"
}
// 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"
}
main "button"
details(["button", "refresh"])
}
}
def parse(String description) {
}
def on() {
sendEvent(name: "switch", value: "on")
}
def off() {
sendEvent(name: "switch", value: "off")
}
Any hints how to turn this into a push button?
Thanks!
Raul