Invert reported state of open/closed sensor?


(Dean Baker) #1

I’m trying to get a sensor to report the state on my garage door. I’ve got a SmartThings open/closed sensor. Unfortunately due to clearance of the tensioner spring and wire and the travel of the carriers in the track, there is no good place to put the sensor in the closed position. What I can do, is put the open/closed sensor at the top of the track, but then it’s backwards, the sensor is “closed” when the door is open… is there any simple way to invert the way it’s reported?


Help me reintegrate my garage door open LED - SOLVED
(Bruce) #2

For a garage door you should only be using the fat part of the ST contact sensor, not both parts. You place it high on the door, attached to the door. It does not matter which vertical orientation it has provided that the long side of the sensor is vertical when the door is closed. The apps that use this accommodate for the vertical orientation being upside right or upside down, whatever that means given there is no up/down marking on the sensor itself.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #3
  1. Use the IDE to create a custom Device Type with the code of the original sensor with just 2 lines changed (open/closed). Let me know and I can paste code here in a few minutes.

(or 2. Create a virtual Device manged by a SmartApp that sets the reverse status of the real sensor… But that’s unnecessary complicated for this situation).


(Dean Baker) #4

the open/closed sensor doesn’t change state except for changes in proximity to the magnet… I’m not sure I understand how I can use just the fat part, can you clarify?


(Dean Baker) #5
  1. yes please, the code to invert it would be wonderful!
  2. I’m too new to this to want to try anything necessarily complicated. :smile:

(Kevin Tierney) #6

I think @bravenel is mixing up the older ST Multi with the newer ST Open/Closed. The ST multi can detect position/angle, but the open/close sensor cannot.


(Eric) #7

If you can’t locate on top the door (where i put a burglar system sensor) then put at the bottom of door.

Multisensor is better - spend a buck.

Otherwise at top of track, you won’t know the door is cracked open or 7/8th’s fully open.


(Kevin Tierney) #8

Try this.I took the ST open/closed sensor device type that is shared in the IDE and modified it

I changed this function

private Map parseIasMessage(String description) {
List parsedMsg = description.split(' ')
String msgCode = parsedMsg[2]

Map resultMap = [:]
switch(msgCode) {
    case '0x0020': // Closed/No Motion/Dry
    	resultMap = getContactResult('closed')
        break

    case '0x0021': // Open/Motion/Wet
    	resultMap = getContactResult('open')
        break

    case '0x0022': // Tamper Alarm
        break

    case '0x0023': // Battery Alarm
        break

    case '0x0024': // Supervision Report
    	resultMap = getContactResult('closed')
        break

    case '0x0025': // Restore Report
    	resultMap = getContactResult('open')
        break

    case '0x0026': // Trouble/Failure
        break

    case '0x0028': // Test Mode
        break
}
return resultMap

}

To This:

private Map parseIasMessage(String description) {
List parsedMsg = description.split(' ')
String msgCode = parsedMsg[2]

Map resultMap = [:]
switch(msgCode) {
    case '0x0020': // Closed/No Motion/Dry
    	resultMap = getContactResult('open')
        break

    case '0x0021': // Open/Motion/Wet
    	resultMap = getContactResult('closed')
        break

    case '0x0022': // Tamper Alarm
        break

    case '0x0023': // Battery Alarm
        break

    case '0x0024': // Supervision Report
    	resultMap = getContactResult('open')
        break

    case '0x0025': // Restore Report
    	resultMap = getContactResult('closed')
        break

    case '0x0026': // Trouble/Failure
        break

    case '0x0028': // Test Mode
        break
}
return resultMap

}

Full device type you can copy/paste in is here:
https://github.com/tierneykev/SmartThings/blob/master/OpenCloseSensor-Inverted


(Jared) #9

Sorry to zombie this thread, but I did as Kevin instructed (swapped those two open/closed), but my sensor is still reading normal. Can anyone advise?


(Jared) #10

Ah, I figured it out. I am using an Ecolink (DWZWAVE2-ECO) contact sensor. I edited the “Z-Wave Door/Window Sensor” device type. I changed this:

> def sensorValueEvent(value) {
> 	if (value) {
> 		createEvent(name: "contact", value: "open", descriptionText: "$device.displayName is open")
> 	} else {
> 		createEvent(name: "contact", value: "closed", descriptionText: "$device.displayName is closed")
> 	}
> }

To this:

def sensorValueEvent(value) {
	if (value) {
		createEvent(name: "contact", value: "closed", descriptionText: "$device.displayName is open")
	} else {
		createEvent(name: "contact", value: "open", descriptionText: "$device.displayName is closed")
	}
}

(Brooklynite) #11

I’m using Samsung sensor for my projector screen so can I change the code for only one sensor?

This is why I’m doing this and why this is important to be made simpler to do. I put the large part on the wall at the low level and the small one is attached to the bottom of my electrical projector screen. When I open the screen it slides all the way down and when its fully opened the sensor reports “closed” and an automated routine activates that turns off most of my lights and dims the hallway to the bathroom to 10% and turns on small LED in the kitchen. Very cool feature. Then when I’m done watching my movie I push the remote for the projector screen and as soon as it starts going up the sensor reports open and starts another automated routine to turn on all my lights at 10% . Its one of the coolest features in my house.

So everything works fine except one thing, the SHM home monitoring which I am starting to hate for its absolute Beta versionisque behaviour. So it keeps reporting that the projector screen door is open. Which to me means the screen is actually closed. And vice versa. So the notifications repeat until I go through the menus to cancel the alert. Also when I look at my list I see an orange text “open” which is not cool. So I wish there was a way to reverse this.

I can see so many other places where this reversal could be handy.