Is there a way to change the icons of this? I am using this virtual switch/contact sensor to trigger Alexa Routines and the icon is being shown as a contact sensor

Is there a way I can change the icons of the following tile, to another icon.
The code being used for this is not made by me but is this,

metadata {

definition (name: "Simulated Alexa Switch", namespace: "bjpierron", author: "bjpierron") {
    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: "", backgroundColor: "#ffffff"
        state "on", label: '${currentValue}', action: "", icon: "st.switches.switch.on", backgroundColor: "#00A0DC"
    main "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")

Is there any what of doing this??

There is, but currently not to an arbitrary icon and only by device handler and not specific devices. You can add a device type to the definition. For example:

definition (name: "Simulated Alexa Switch", namespace: "bjpierron", author: "bjpierron", ocfDeviceType: "oic.d.switch")

I tend to use oic.wk.d which is a generic icon.


Thank you so much! I did read about that before but didn’t get it to work. Now it is working for me. Maybe there was that one letter that was not meant to be there.
Anyways, thanks for your help and enjoy your day!

Hello to change the state?
open = on
closed = off

While you were posting that, I was responding to your other post.


Thanks it worked