Presence detection

I try to set up a new way of presence detection since the iCloud Binding is not working anymore.
My approach is to use the network binding and mobile devices state. If my mobile device is online, i am at home. If it is offline, i am away.

The problem is that the mobile device changes to offline when it is not used for some time.
I want to change my presence state only after my mobile was offline for a longer time.
To do that I want to use a dimmer item. Every 5 min I check the state of my mobile. If it is off, I want to increment the dimmer. Once the dimmer has reached 100, I want to change the presence status to off.

I was reading many threads to find out how to save the state of my dimmer to a variable. But I always get the following error. ZaehlerA is my dimmer item. My DSL script looks like this:
script

This is the error message in the Log:

I am using openhab 3.3.0 on a raspberry py.

Try as Number (capital N)

1 Like

Maybe just try it with a timer:

If the mobile goes offline, start a timer eg. for 15 min
If your mobile goes online again cancel the timer

As an alternative, this seems promising.

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