Reverse an Iris contact sensor

Hello all,

Could someone help me with the subject?

The only catch is that I would like the temperature monitoring (with ability to enter manual +/-adjustment) and battery monitoring to remain useable.

To my understanding this is a zigbee device.

The device handler would read “open” when the sensor and magnet are together, and “closed” when they are apart?

Make a simulated sensor. have it report open when the physical device is closed and vice versa.

@Wtstreetglow, what @anon36505037 said is your best solution.


@anon36505037 I am using the default device handler. And yeah, to be more specific, I meant when the magnets are together, show open and vice versa.

@johnconstantelo Thank you!!

@anon36505037 Thank you so much for that help!! So I am just reversing those in the device handler code. Amazing, I didn’t think it would be that easy. Thank you all so much!!

@Wtstreetglow - Just to be clear the above code change is only reversing the display of the device, not the value. So if this is being used in a routine for something it will still work as a stock device. Is that the intent?

Well, my plans were to soon set up something that would send myself a text message when the door is opened. The magnet comes closer to the sensor when the door is opened and is why I really would like to have everything work in an inverse fashion.

As I understand, now my visual displays in the app will be correct. But are you saying the routines that rely on the state of the device will still be backwards in my situation?

I think I am following you but not completely sure…

Yes…that code changes the label but the “state” of the device is still the same. So your routines will still work exactly as if you didn’t make a change. What you are asking, I believe, is to reverse the state of the device. So when its “open” the device itself thinks its “closed” and vice versa. Still doable in the device handler but a little more complicated.

I would as others mentioned use a virtual device, when your device opens the virtual gets commanded closed and when it closes the virtual gets commanded open. Then use the virtual in your routines.

With that said can’t you use a custom routine in Smart Home Monitor to do what you want? You can say “When xxxx door opens send a alert”. It works on open or closed.


@vseven Yes, what you are saying is what I am wanting to do. Not just invert the status. I am actually wanting the reverse the state of the device…

Can you all help me with that?

Try this, set the sensor to control a virtual switch, and the switch control a virtual open / close sensor that can reverse the operation.

Before you go through the work to do this what exactly do you want to happen? Get a alert when a door opens? If so you can do that with no modifications to anything. Or am I missing something?

I would just use webCoRE and make the rule accordingly…

If open then this
If close then that

Truthfully, I use webCoRE for most of things now…

If its a simple as “If door open send alert” why would you not use a custom rule in Smart Home Monitor that runs locally? I know SHM custom rules have limitations but for something this simple it makes sense. Unless like I said I’m missing something the OP is trying to do.

1 Like

@vseven I like simple. Is smart home monitor a smartapp? Also, can it handle the fact that even though the sensor is reporting the state closed, the door is actually open and vice versa?

Pretty much in my situation, the magnets get close together when the door is open, so the contact sensor is always reporting the opposite of what it really is.

So when I view the smartthings app, I would like it to display correctly but also I would like it to report state correctly just in case I use it in a routine or something that pulls the devices state to trigger something else.

I’m sorry I am new with all of this so if my explanations are no bueno. :frowning:

Smart Home Monitor is the “built-in” app, there is nothing to install. When you go into the app you sbould see it on your “dashboard” view. Click on it then the gear icon then Custom. You can make a rule to do exactly what you want, notify you when a door opens or closes or anything else in the house happens.

1 Like

@vseven Oh lord, I didn’t even know that was a built in feature. Awesome. So will it always tell me the opposite state though? (The way it is now…)

And if I change just the view attribute in the code as stated by a user above, is that the direction I should go? Or should I go the virtual switch direction?

A lot of this is very new to me.

@vseven I think I see now. Setup the virtual device and then reference the virtual device in the alert routine?

I’m saying I don’t know why you need to setup a virtual device at all. Just setup the alert how you want (open or closed…what its actually reporting) and be done.