Rule to prevent false-activations of sensor

Hi,

installed a sensor in my bed to detect presence and linked it to openhab. I’d like to make a rule to prevent false-activations (like just sitting down in bed for a short time,… ). What would be the best approach? Thanks!

what kind of sensor? Passive infrared (PIR) motion sensor?

explain the scenario a bit more… what means “false activation” what do you want to avoid ?
The sensor will detect motion and activate… that’s not a false condition.

Can’t write rules until you work out what it is that you want to happen.
You seem to be looking for a way to distinguish between “someone sleeping in bed” and “someone sitting on bed”.
I guess the actual sensor cannot tell the difference, but we might be able to come with some ideas.
How long they are there is an obvious factor.
Perhaps sleep only happens when it is dark and the room light is off.
Perhaps sleep only happens between certain times of day.

It’ll never be perfect - what happens if someone is sick? How important errors are depends on what you are doing with the information. Turning on a light might not matter; ringing an alarm bell might. You might need a way to override or avoid actions.

It’s a weight-sensor under the bed.

I think this would be a great start. Let’s say i want to trigger a switch when my sensor was active for 5 minutes. I wanted to make a rule with a timer but i don’t know how to determine if the sensor was active the whole time during the duration of the timer (and not only when the timer ends)…

One way to approach this rule is create a proxy item (virtual item), use the Expire binding for a timer, use logic needed in the if else etc… that match what your wanting to do.

If you need help getting started let us know.

Here’s a link that will help explain some of the conditional statements you’ll need https://www.w3schools.com/js/js_if_else.asp

Okay, so you’d set up a timer that was accessible from multiple rules.
When the sensor changes to “occupied”, start the timer.
When the sensor changes to “unoccupied”, cancel the timer.
If the timer runs to completion, do whatever was wanted.

1 Like

Would it need debounce?