Presence Detection Seems Too Hard

I’ve installed Openhab on a raspberry Pi and have my lights controlled with it now. I’m by no means an expert, but I think I wanted to make sure I had something working before I posted here.

I’m trying to sort out presence detection. My first hope was to use Google WiFi as they have a great page for looking at what devices are connected. Alas, there’s not a good way to do this directly (I’m not switching to static IPs). I decided to incorporate IFTTT as a middle man from the Goggle Wifi connection, but that’s down. Next I looked at Owntracks. I have it setup on my phone, but I can’t get anything to show up in myopenhab despite following instructions and reading through the forums.

Here’s what I’m looking to do. I want to know when specific devices are home. I also want to know when other people are present so I can modify behavior. Any suggestions? I’m pretty stuck and frustrated.

The GPS tracker with Owntrack or GPS Logger is to me the best choice, and it’s more reliable than the network binding because sometimes the Phone doesn’t answer the ping request and openHab understands as if you were away from home.

Presence detection is, as you say, hard. It’s particularly hard with multiple people in the house, because you can’t plan for every possibility (such as someone forgetting their phone at home). You can’t even be sure that a device has left the property…it might just be turned off.

I tried the IFTTT route, and you’re not missing anything. It’s really slow to update, which makes it almost useless for entering a zone (though fine for leaving). On Android devices you can use Tasker to trigger via the openHAB app, but I’ve also found Tasker’s geofencing to be mediocre. And to be fair, that’s just because devices don’t update their positioning constantly (I assume to preserve battery power).

Can I ask why you’re against static IPs? openHAB’s network binding is really quick to pick up when a device appears on WiFi, and I’d say that this is one of the fastest ways to detect a device. There’s nothing particularly bad about static IPs from a networking perspective, and the work is minimal if you’re only doing it for a few devices.

I can’t remember where I read it here, but I think the best suggestion was to use multiple vectors for determining presence, so that you’re not relying upon one method to work every single time.

Personally, I find it to be too much of a bother, so I just resolved to having an “Away Mode” switch. I tell Google Home that I’m leaving, and it turns Away Mode on. When I get home, Away Mode turns off when I unlock my door or trip the motion sensor. And then it’s off until I intentionally turn it on again. Yes, it’s less automated, but it also means that if I reboot my phone, Away Mode isn’t going to suddenly activate and turn off all of the lights.

I’m not saying that you should give up on presence detection, but that it’s very tricky to get working in a reliable way…particularly when there are multiple humans in your household. :wink:

Presence Detection IS hard.
IFTTT is slow, prone to error and depends on external resources. To me a no-go.
There’s people to use Tasker. Most I know of use WiFi arrival/leave detection but certainly not with G**gle but their own WiFi router. Also many to use owntracks / gpstracker binding, but I’m not sure how to do it in the context of myopenhab.
My favorite is FIND which is included with openHABian but it needs an update. Too much work, too little time these days.

There is a pretty old but nevertheless pretty current thread with a rather complete overview on presence detection solutions here.
I also gave a talk on last but one smarthome day which can be found here.


Only general advice here - don’t rely on any “magic solution”. Some methods may be more reliable or timely than others, but all have their place.
The most effective ‘Presence’ solutions combine info from several sources.
Get each method working as best it can individually, and devise a means to combine data.

Indeed. There’s also some hints how to combine multiple sources in the presentation I linked to.


after tuning up network a bit, I have pretty reliable iphone detection based on network binding.
I mean, granularity of 15min is enough for me to know if some phones are home or not.

But by any mean I wouldn’t rely on those informations for any kind of automation. I mean, what if your phone is left in the office or otherway round, it’s home when you are not etc.

Agreed presence detection is definitely hard, due to too many combinations of people/devices, home or just left device at home etc. It really needs to have multiple presence detections and some smart algorithms to work it all out.

Having said that, and not to hijack your thread… but to supplement other presence detection methods I’m going to create a basic vehicle presence detection. If both my and my wifes car are out, then it’s safe to assume that we are both not home (although kids maybe still, phones can be checked - they are constantly on them!) If one or both cars are home, then it’s safe to assume we are also home (again, this is supplementing phone presence and other methods, as it’s possible we have all gone out in one car lol!)

The way I see it working, is an ESP8266 wifi chip that sits under the dashboard of the car (perhaps with half decent aerial on it) and is powered up only when the ignition is on / car is started up. It would then immediately connect to the wireless AP and let OH know via MQTT messages that the car is at “Home”. So the first part of the solution is determining that the car is at home (because it’s Wifi is connected) or not at home (Wifi is disconnected) Of course, if it’s connected to Wifi because it’s home, but then the car is turned off thus powering off the ESP8266, it then needs to determine “has the car been turned off at home” or “has the car left home and wifi is simply out of range” To determine this, I figured constantly monitoring it’s own Wifi signal strength (assumes of course, the car when sitting in your garage is close enough to the AP for reasonable signal to start with) If the signal slowly gets weaker and weaker (RSSI drops), then the ESP8266 sends “Leaving” via MQTT, then when LWT (last will and testament) kicks in it changes to state to “Away”. If the Wifi strength stays the same or gets stronger, it sends at “Home”. An alternate thought was to have the ability to monitor whether it’s on the cars ignition power, add in a capacitor to keep it running (even for say 10 seconds after the car is switched off) then it would categorically know that it’s at “Home” (and simply been turned off)
Something like that anyway, need to work out the logic. I’d also prefer to have the smarts programmed into the ESP chip itself, rather than relying on some sort of binding etc to do anything at the OH end. I don’t really need GPS tracker for my car, all I simply want to know is whether the car is home or away. The wifi idea is a bit more rudimentary, however it would still allow rules to run like automatically opening garage door, turning lights on etc when the car turns up.

Oh, and totally agree with @mstormi - IFTTT is crap. Too much dependence on cloud when running what’s mostly local home automation is too much risk.

1 Like

This is my preferred method at the moment, at least on my personal device. However, I can’t seem to get it working at all. I’m not sure how to diagnose whether I’m getting anything into myopenhab or if the hangup is getting to openhabian.

You should be able to test with curl to determine if your device on the Internet can update the status of myopenhab and rule out some of the troubleshooting.

When I finally get to presence detection, this is my current plan as well. Instead of using Google Home I’m going to use the setting of the security system to trigger “Away” mode. If the security system is armed “Away”, nobody’s home. I already have the security system integration, and we all push the buttons to arm it when we leave, and we all disarm it when we come in.

1 Like

That way works fine, when you´re living on your own. But in a family with more members, this isn´t going to work, unless everyone tells when they´re leaving, and again, when they arrive… Not optimal :slight_smile:

this works just fine, as many of houses (or us) having regular alarm which kind of need to type something in to be IN or OUT :smiley:

Good afternoon, I propose one of my solutions, (I hope these next vacation to do it). It is very simple, it is a simple hanger, where to place for example house keys, car etc. Use a contact sensor, in my case of xiaomi, since it is very small, The function is that when placing the keys, bring the part that has the greatest weight, to the part of the magnet, and close the contact, this would send us to OPENHAB the signal indicating the state of closed and in maps, we define what interests us. I think it is a simple solution, but in micaso it is functional.
Forgive my English, it’s Google translation.

1 Like


If you assign static IPs to these devices on the router the problem becomes very simple. You just need the Network binding.

This is really hard and I’m not sure I’ve seen anyone provide a solution to this beyond motion sensors. You could use something like reelyActive Smart Spaces Revisited and see when any device with BT turned on is present, but you cannot uniquely identify any given device because most will periodically change their BT address as a privacy/anti-tracking feature. And you will have no way to tell whether that someone is supposed to be there or not.

I found just the opposite, with up to a 30 second to 1 minute lag between my entering an area and actually being reported in that area. A well tuned Network binding with arping will see any device, whether it is sleeping or not, within 5 seconds.

Check out AutoLocation which is better, but GPS is still pretty slow to update. But you can use other stuff in Tasker which may work better such as 'WiFi Near or 'Cell Tower Near.

This is why the Generic Presence Detection tutorial has a flapping timer. Only if the phone is off for five minutes would it count you as away. And there is an override switch that you could flip if you know the phone will be offline for longer. I use that when we have a baby sitter over to stop all the “blah blah happened and no one is home!” alerts.

I believe it still let’s you define a geofence that triggers a Switch when you enter/leave the geofence. But that was before the new GPS Tracker binding so I don’t know if that is still possible.

It’s worth mentioning that FIND doesn’t work with iOS, unless something has changed since the last time I looked. It’s one my list of things to play with at some point, too little time myself.

That’s what the override switch is for. And the general advice (I figured it was common sense but may it isn’t) that nothing critical should be driven by any presence detection that isn’t 100% solid whether you have a device on your person or not, which is reaching the edge of what is technically feasible frankly. If you don’t have enough time to manually flip the override Switch or manually do something to avoid alarms or something when you arrive home without your phone, you should be relying on presence to drive that automation.

Yeah I use alarm as well. When alarm is armed, no is at home, (hopefully :slight_smile: ). Problem is, if last person leaves without activating the alarm.
I have thought about a way to automate this, but it´s not stable enough, as I want it to activate as soon as last person leaves the house… But what if the last person only leaves a few meters from the house, forget the key/phone/any triggering part… Not good.

For detecting who is home, I use Unifi binding to detect the phones. It´s working quite good. But it takes a few minutes to detect when someone has left the house (aprox 5 minutes).

Per my earlier post, I only need to tell Google Home when I’m leaving. openHAB detects when I arrive home via my lock or motion sensor. So all that this requires is for people to turn the away/alarm mode on when they leave. That’s not a difficult task.

This is exactly why manually turning the away/alarm mode on is, in my opinion, the optimal solution (regardless of how many people there are in the house). It removes the biggest source of unpredictability (humans) from the equation.

I think your concern is that the last person will fail in their task of turning on the alarm. I acknowledge that that can happen, but I trust a family member to make the right decision more than I trust a set of rules that can’t account for every possible scenario (particularly rules that I’ve programmed). I think it’s better to leave the complex processing to a person who can easily determine whether or not others are still in the house.

Not only do I trust my family members more than rules I might write to try and guess every situation, by tying the “Away” to the security system it’s easier to remember to engage - there is more at risk than just the HA system, and people seem willing to deal with the annoyance of the security system for its perceived benefits.

One reason I haven’t moved far forward on this is I’ve discovered how rarely we all actually leave… :slight_smile:

Whenever face detection gets better and more stable to use, I believe this is will the revolutionary thing in the whole aspect of presence detection. Just like voice recognation, the two together will finish what we all ask for. I look forward to that day!

It does, but it´s hardly automated :slight_smile:

Naah, it´s not really a question of trust, (even though some part of the family do tend to forget once in a while). It´s more a question of automating things like these insted of dealing with it. You can forget to tell your GH that you´re leaving, just as well as you can forget to activate the alarm.
What if you´re in an extreme hurry, you tell GH you´re leaving, but something goes wrong and it doesn´t respond. You dont have time to deal with it.
Also there are situations where it´s not necessary to activated the alarm. Perhaps you just leave the house to go into the garden or just nearby. Ofcouse it wont hurt to activate the alarm or lock the door (unless you forget the key). And it doesnt hurt if the house thinks you have left the building. But it would be better trying to deal with these situations, if possible though.