I hope that this hasn’t been covered somehow, as it should be a easy fix… I think. Perhaps my Google skills are subpar. For the below code, all that I am trying to do is generate state changes when a contact opens or closes. I get events just fine; the list of “frontDoor is open”/“closed”, etc, but it never changes the icon and thus, to my understanding, never registers as open or closed for alarming purposes.
Can anyone point out what I’m doing wrong?
// Device Handler
metadata {
definition (name: “DoorContactSensors”, author: “Daniel Ogorchock”) {
capability “Contact Sensor”
}
// UI tile definitions
tiles {
standardTile("frontDoor", "device.contact", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:'Front Door', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:'Front Door', icon:"st.contact.contact.closed", backgroundColor:"#79b821", defaultState:true
}
standardTile("deckDoor", "device.contact", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:'Deck Door', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:'Deck Door', icon:"st.contact.contact.closed", backgroundColor:"#79b821", defaultState:true
}
standardTile("basementDoor", "device.contact", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:'Basement Door', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:'Basement Door', icon:"st.contact.contact.closed", backgroundColor:"#79b821", defaultState:true
}
standardTile("garageDoor", "device.contact", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:'Garage Door', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:'Garage Door', icon:"st.contact.contact.closed", backgroundColor:"#79b821", defaultState:true
}
main (["frontDoor","deckDoor","basementDoor","garageDoor"])
details (["frontDoor","deckDoor","basementDoor","garageDoor"])
}
}
def parse(String description) {
def name = null
def value = zigbee.parse(description)?.text
def result
// Don't care about ping
if (value == "ping" || value == " ")
{
return
}
def linkText = getLinkText(device)
def descriptionText = getDescriptionText(description, linkText, value)
//log.debug "Description is ${value}"
def incoming_cmd = value.split()
name = incoming_cmd[0]
value = incoming_cmd[1]
if ( value == "open" ) {
sendEvent(name: name, value: value, isStateChange:true)
result = createEvent(name: name, value: value)
log.debug "test '${name}'='${value}'"
}
if ( value == "closed" ) {
sendEvent(name: name, value: value)
result = createEvent(name: name, value: value)
//log.debug "test '${name}' is closed"
}
}