Reverse an Iris contact sensor


(Weston T Turner) #1

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.


(Robin) #2

I don’t get the question?

What do you mean by ‘reverse’?


(Mark) #3

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


(Robin) #4

I don’t have this particular device but the principle of what your asking is easy enough to change in the code.

Are you using a default device handler or custom?


(Glen King) #5

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


#6

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


(Robin) #8

Use this handler (I think):

https://raw.githubusercontent.com/mitchpond/SmartThingsPublic/master/devicetypes/mitchpond/iris-open-closed-sensor.src/iris-open-closed-sensor.groovy

Change:

attributeState “open”, label:’${name}’, icon:“st.contact.contact.open”, backgroundColor:"#ffa81e"

attributeState “closed”, label:’${name}’, icon:“st.contact.contact.closed”, backgroundColor:"#79b821"

To:

attributeState “open”, label:‘Closed’, icon:“st.contact.contact.closed”, backgroundColor:"#ffa81e"

attributeState “closed”, label:‘Open’, icon:“st.contact.contact.open”, backgroundColor:"#79b821"

You could also swap over the hex colours if desired…


(Weston T Turner) #9

@RobinWinbourne 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.


(Weston T Turner) #10

@johnconstantelo Thank you!!


(Weston T Turner) #11

@RobinWinbourne 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!!


(Allan) #12

@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?


(Weston T Turner) #13

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…


(Allan) #14

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.


(Weston T Turner) #15

@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?


#16

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


(Allan) #17

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?


(Ron Talley) #18

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…


(Allan) #19

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.


(Weston T Turner) #20

@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:


(Allan) #21

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.