How do you format the action on a tile so that it calls a function and passes a parameter?
I currently have to create a separate on and off function for each of the eight ports instead of calling the one function that accepts two parameters…
I know the function works because I can add a command and trigger it from the IDE like:
command “OutletAction”, [“string”], [“string”]
I just can not figure out the right syntax to get it to fire from the action.
//CURRENT TILE
standardTile(“Outlet1”, “device.Outlet1”, width: 1, height: 1) {
state “off”, action:“on1” , label: “Off”, backgroundColor: “#ffffff”, nextState: "on"
state “on” , action:“off1”, label: “On” , backgroundColor: “#79b821”, nextState: “off”
}
//CURRENT FUNCTION
def on1() {
log.debug "Send Outlet 1 ON"
def uri = "/outlet?1=ON"
postAction(uri)
}
//WANTED TILE
standardTile(“Outlet1”, “device.Outlet1”, width: 1, height: 1) {
state “off”, action:‘OutletAction(“1”,“ON”)’ , label: “Off”, backgroundColor: “#ffffff”, nextState: "on"
state “on” , action:‘OutletAction(“1”,“OFF”)’, label: “On” , backgroundColor: “#79b821”, nextState: “off”
}
//WANTED FUNCTION
def OutletAction(outlet,action) {
log.debug "Send Outlet ${outlet} ${action}"
def uri = "/outlet?${outlet}=${action}"
postAction(uri)
}