Change virtual contact sensor options?


#1

I’m using a simulated contact sensor to show status of two real contact sensors being controlled via webCoRE, but one thing I’ve noticed about virtual contact sensors is they can be controlled in the SmartThings app simply by pressing them and it’ll change status from open to close to open easily. My question is this: can I prevent status from being changed through button pushes and limit it to only webCoRE changes?


#2

Start with the raw DTH:

Change:

tiles {
		standardTile("contact", "device.contact", width: 2, height: 2) {
			state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#00A0DC", action: "open")
			state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#e86d13", action: "close")
		}

To (remove both actions):

tiles {
		standardTile("contact", "device.contact", width: 2, height: 2) {
			state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#00A0DC")
			state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#e86d13")
		}

#3

Thank you so much! I’m comfortable with updating from the repo and copying pasting code, but actual editing of code is still a bit intimidating.


#4

@Robin can this same edit be done to virtual switches? Trying to use a switch that can’t be controlled in SmartThings app - only programmatically.


#5

If you have the device handler to modify, search for action like the one in Robin’s example and delete that part. You’ll have 2, one for on and one for off. Give that a try.


#6

You’re right I got it! Thanks!