Here is my code for the device handler. I tried putting the send event in a few places and couldnt get it to work.
As of right now only pink and blue have two states, the other colors will come when I figure out how to change their background based on another tile press.
capability "Actuator"
capability "Switch"
capability "Switch Level"
capability "Sensor"
attribute "whitestate", "string"
command "blue"
command "pink"
command "red"
command "green"
command "orange"
command "yellow"
command "purple"
command "skyblue"
command "rainbow"
command "white1"
command "white2"
command "white3"
command "white4"
}
// Simulator metadata
simulator {
status "on": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E"
status "off": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666"
// reply messages
reply "raw 0x0 { 00 00 0a 0a 6f 6e }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E"
reply "raw 0x0 { 00 00 0a 0a 6f 66 66 }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666"
}
// UI tile definitions
tiles {
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821", nextState:"off"
state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff", nextState:"on"
}
standardTile("Blue", "device.switch.blue", height:1, width:1) {
state "off", label: 'Blue', action: "blue", icon: "st.illuminance.illuminance.light", backgroundColor: "#ffffff", nextState:"blue"
state "blue", label:'Blue', action:"off", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#0276FD", nextState:"off"
}
standardTile("Pink", "device.pink", height:1, width:1) {
state "off", label: 'Pink', action: "pink", icon: "st.illuminance.illuminance.light", backgroundColor: "#ffffff", nextState:"pink"
state "pink", label:'Pink', action:"off", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#f934f3", nextState:"off"
}
standardTile("Red", "device.red", height:1, width:1) {
state "red", label:'Red', action:"red", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#ff0000"
}
standardTile("Green", "device.green", height:1, width:1) {
state "green", label:'Green', action:"green", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#00ff00"
}
standardTile("Orange", "device.orange", height:1, width:1) {
state "orange", label:'Orange', action:"orange", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#ff9900"
}
standardTile("Yellow", "device.yellow", height:1, width:1) {
state "yellow", label:'Yellow', action:"yellow", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#ffff00"
}
standardTile("Purple", "device.purple", height:1, width:1) {
state "purple", label:'Purple', action:"purple", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#660066"
}
standardTile("Skyblue", "device.skyblue", height:1, width:1) {
state "skyblue", label:'Skyblue', action:"skyblue", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#00ccff"
}
standardTile("Rainbow", "device.rainbow", height:1, width:1) {
state "rainbow", label:'Rainbow', action:"rainbow", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#9966ff"
}
standardTile("White", "device.whitestate", height:1, width:1) {
state "1", label:'White', action:"white1", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#ffffff", nextState: "2"
state "2", label:'White 1', action:"white2", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#ffffff", nextState: "3"
state "3", label:'White 2', action:"white3", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#ffffff", nextState: "4"
state "4", label:'White 3', action:"white4", unit:"", icon:"st.illuminance.illuminance.light", backgroundColor: "#ffffff", nextState: "1"
}
main "switch"
details ("switch","Blue","Pink","Red","Green","Orange","Yellow","Purple","Skyblue","Rainbow","White")
}
}
// Parse incoming device messages to generate events
def parse(String description) {
def value = zigbee.parse(description)?.text
def name = value in ["on","off"] ? "switch" : null
def result = createEvent(name: name, value: value)
log.debug "Parse returned ${result?.descriptionText}"
return result
}
// Commands sent to the device
def on() {
zigbee.smartShield(text: "on").format()
}
def off() {
zigbee.smartShield(text: "off").format()
}
def blue() {
zigbee.smartShield(text: "blue").format()
}
def pink() {
zigbee.smartShield(text: "pink").format()
}
def red() {
zigbee.smartShield(text: "red").format()
}
def green() {
zigbee.smartShield(text: "green").format()
}
def orange() {
zigbee.smartShield(text: "orange").format()
}
def yellow() {
zigbee.smartShield(text: "yellow").format()
}
def purple() {
zigbee.smartShield(text: "purple").format()
}
def skyblue() {
zigbee.smartShield(text: "skyblue").format()
}
def rainbow() {
zigbee.smartShield(text: "rainbow").format()
}
def white1() {
zigbee.smartShield(text: "white1").format()
}
def white2() {
zigbee.smartShield(text: "white2").format()
}
def white3() {
zigbee.smartShield(text: "white3").format()
}
def white4() {
zigbee.smartShield(text: "white4").format()
}