Thanks to @storageanarchy further guidance I got this working so to hopefully help other people I’ll post my code. With it you can display anything for the labels while the underlying device still maintains it’s standard states. This is based on @ogiewon ST_Anything child contact sensor (comments, header, extra stuff not important removed):
metadata {
definition (name: "Child Contact Sensor", namespace: "ogiewon", author: "Dan Ogorchock") {
capability "Contact Sensor"
capability "Sensor"
}
preferences {
section("prefs") {
input(name: "openDisplayLabel", type: "text", title: "Enter the text to display when the contact is open.", multiple: false, required: true, default: "Open")
input(name: "closedDisplayLabel", type: "text", title: "Enter the text to display when the contact is closed.", multiple: false, required: true, default: "Closed")
}
}
tiles(scale: 2) {
multiAttributeTile(name:"contact", type: "generic"){
tileAttribute ("device.contactDisplay", key: "PRIMARY_CONTROL") {
attributeState "Open", label:'${currentValue}', icon:"st.contact.contact.open", backgroundColor:"#e86d13"
attributeState "Closed", label:'${currentValue}', icon:"st.contact.contact.closed", backgroundColor:"#00a0dc"
}
}
main "contact"
}
}
def updated() {
//log.debug("Updated called. Update labels if changed.")
updateLabels(device.currentValue("contact"))
}
def generateEvent(String name, String value) {
log.debug("Passed values to routine generateEvent in device named $device: Name - $name - Value - $value")
// Update device
sendEvent(name: name,value: value)
updateLabels(value)
}
def updateLabels (String value) {
//log.debug("updateLabels called. Passed value is $value. openDisplayLabel is $openDisplayLabel. closedDisplayLabel is $closedDisplayLabel.")
// Update tile with custom labels
if (value.equals("open")) {
sendEvent(name: "contactDisplay", value: openDisplayLabel, isStateChange: true);
} else {
sendEvent(name: "contactDisplay", value: closedDisplayLabel, isStateChange: true)
}
}
Hopefully this makes sense. I personally have Open = Off and Closed = Running for a electric heater in my garage although for testing it was “Suck It Trebeck” and “Anal Bum Cover”.
-Allan