Presence detection

That’s way more complicated than necessary.

What you need is a debounce which is a term of art in electronics. It basically means “ignore any changes to that switch for a certain amount of time after the first event.” For example, when you press a button the spring may bounce a few times before it settles and as it’s bouncing it may close the circuit. So a debounce ignores those bounces for a few milliseconds.

In your case you need longer times but the concept is the same.

See Generic Presence Detection for a few different ways to achieve this. One is to use the Debounce [3.2.0;3.4.9] rule template. If you use this, you won’t need to write any code at all. Just add some metadata to the presence Items and a proxy Item.

But if you want to code this yourself in a rule, there’s a Python and Rules DSL implementation that uses Timers like @Matze0211 suggests.

In addition, if you are in the Android world, the OH Android app can update an Item with the name of the SSID the WiFi is connected. You could (and I currently do) use this to track my presence. If you have Tasker, you can make it even better and detect the networks that are nearby and report those to an Item instead of only reporting the names of the networks connected to.

But I still use a debounce when I leave so that when I am in the back part of the property or at the mail box for a minute or to it doesn’t mark me as away.

2 Likes