Alexa Virtual Switch Change Label Status

Hi, I would like to change the status text in the device handler below with ON and OFF

metadata {

definition (name: "Simulated Alexa Switch", namespace: "bjpierron", author: "bjpierron", ocfDeviceType: "oic.d.switch") {
    capability "Switch"
    capability "Sensor"
    capability "Actuator"
    capability "Contact Sensor"	    		
}

simulator {
	status "open": "contact:open"
	status "closed": "contact:closed"
}

tiles {
    standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
        state "off", label: '${currentValue}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
        state "on", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00A0DC"
    }
    main "switch"
    details(["switch"])
}

}

def parse(description) {
}

def on() {
sendEvent(name: “switch”, value: “on”)
sendEvent(name: “contact”, value: “open”)
}

def off() {
sendEvent(name: “switch”, value: “off”)
sendEvent(name: “contact”, value: “closed”)
}

1 Like

You mean the status in the dashboard tile? Change the definition( ... ) to

definition (name: "Simulated Alexa Switch", namespace: "bjpierron", author: "bjpierron", mnmn: "SmartThingsCommunity", vid: "e7139f27-316b-3400-80be-9581014a7434" )

If you want the icon to change as well, you can change the end bit to:

vid: "e7139f27-316b-3400-80be-9581014a7434", ocfDeviceType: "oic.d.switch" )

Forgot to mention to make the app take notice immediately, edit the device in the IDE, change something significant like the device name or the device label and then ‘Update’.

Update: Just noticed the oic.d.switch mod was in the original post. I had pulled the original DTH.

2 Likes

Thanks it worked!!!

Thanks for posting this. I much prefer the switch to the contact sensor.

2 Likes