The use of "Exit rule" as last resort (Double check before alerting)

Need some advice please

I have a sensor on my garage door. I have a rule alerting me when the garage door is open for +10min. The rule is working fine but sometimes the garage door is closed and I still get an "open door" alerting.
The door sensor shows the correct status. (closed), but the sensor has sometimes multiple on/off events and this may cause the problem. (In general it can be problematic when reed sensors slide in from the side, the magnetic field changes will make it think it opens and closes multiple times.)

I added an extra check before the Open Door alerting starts that results in an "Exit Rule" when the door is closed.

Is this the correct action to use In this case? (very difficult to test because I cannot provoke the problem)

Personally I think the "IF Garage Door closed" should be the very first statement followed by all your ELSE statements with the EXIT RULE after your set privat boolean false.
Then follow with your If Garage Door is Open in a new ELSE - IF.

So.
IF (Garage Door closed) THEN
Cancel Delayed actions
Stop Repeating Actions
IF PB is true............
Set PB False
Exit Rule
ELSE-IF (Garage Door open) THEN
Delay
SET PB True
Repeat every
Set Vol
Notify
END-REP
END-IF

Just seems better to me but I may have it all wrong.

1 Like

BTW there is this app which may help you with the 'bounce' problem.

definition(
    name: "Debounce contact",
    namespace: "hubitat",
    author: "Bruce Ravenel",
    description: "Debounce double reporting contact sensor",
    category: "Convenience",
    iconUrl: "",
    iconX2Url: "")

preferences {
	page(name: "mainPage")
}

def mainPage() {
	dynamicPage(name: "mainPage", title: " ", install: true, uninstall: true) {
		section {
			input "thisName", "text", title: "Name this debouncer; debounced contact device will have this name", submitOnChange: true
			if(thisName) app.updateLabel("$thisName") else app.updateSetting("thisName", "Debounce contact")
			input "contact", "capability.contactSensor", title: "Select Contact Sensor", submitOnChange: true, required: true
			input "delayTime", "number", title: "Enter number of milliseconds to delay for debounce", submitOnChange: true, defaultValue: 1000
		}
	}
}

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
	unschedule()
	initialize()
}

def initialize() {
	def debounceDev = getChildDevice("debounceSwitch_${app.id}")
	if(!debounceDev) debounceDev = addChildDevice("hubitat", "Virtual Contact Sensor", "debounceSwitch_${app.id}", null, [label: thisName, name: thisName])
	subscribe(contact, "contact", handler)
}

def handler(evt) {
	runInMillis(delayTime, debounced, [data: [o: evt.value]])
	log.info "Contact $evt.device $evt.value, start delay of $delayTime milliseconds"
}

def debounced(data) {
	log.info "Debounced contact $data.o"
	def debounceDev = getChildDevice("debounceSwitch_${app.id}")
	if(data.o == "open") debounceDev.open() else debounceDev.close()
}
1 Like

Ok, I understand, but the issue I trying to solve is:
The rule is still running while the door is closed, just before the alerting I do a last check of the status of the door (to be sure, a double check)
You should expect If the rule is still running the door is open but sometimes it is not... (Topic)

1 Like

Appreciate what you are saying but my rule comments were mainly because your title was about the use of 'Exit Rule' and that is how I would do it for the rule you showed us.

I'm not sure if you noticed but I sneaked in another post with an app that may help with the issue you are seeing.
I'd be interested to know if it works for you because I've tried configuring/playing with mixed results.
I'd be interested to know how you get on with it if you do try it.

2 Likes

the problem is, I cannot provoke the problem... sometimes it is there, sometimes not for weeks/months...

Yeah. These are the worst ones to try and mitigate for.

I had a similar issue with my motorised curtains.
I ended up getting some of those really strong magnets off of ebay.
After a bit of playing to get them in just the right place, it has cured the problem.
As you say though, if it doesn't happen all the time it's a pain in the butt.

Something like these.

1 Like

I would suggest using notifier for the notification portion. It won't notify if the state changes within the time frame

2 Likes

I guess you mean the app "Notifications".
I want a confirmation if the door is closed ONLY after it was to long open, This is not possible with "Notifications"

ahhh, gotcha. then RM would be the right thing