Presence Detection with iPhone and OH2

Hi,

I’ve read a lot about presence detection but I am still lost.

I want to use our iPhones to implement a presence detection. One use case is to implement different rules according to presence state but ideally the system would also recognize if an iPhone logged into WiFi, so - for example - the entrance hall lights would turn on for 2 minutes if one of us approached the front door.

Which reliable ways currently exist to implement presence detection via iPhone (6s running iOS 10.x)?

Thanks in advance
Sven

Feel free to search the forum; there are quite a few post describing it in details…

One just posted today

Hi Sven.

I am also working on making presence detection working, here is what I know so far.

Forget WiFi, iPhones have a habit of turning WiFi off when sleeping and so on.
Bluetooth might be a better option, depending on the size of your home. I have tried to get this working, but haven’t been too succesfull in the use of some scripts I found. However I am able to ping and find the phone, just haven’t turned it into a script.

The best option I have seen so far is to use the “find my iPhone” feature from iCloud. I haven’t tried this yet but take a look here on the forum and this bridge/script :slight_smile:

Hey @GigabitGuy!

I’m trusk that created that script. Even tough it pleases me that I still see people using it, I want to add to something you said

Forget WiFi, iPhones have a habit of turning WiFi off when sleeping and so on

While this is true, they still keep some sort of, let’s call it “idle wifi connection” to the router. This means, even when the phone is in sleep, the router still knows the iPhone is in the network. Based on this, if you have a router which can run scrips, something with DD-WRT, Tomato, Asus Merlin, etc, you can run a script 24/7 on the router which notifies OH of the phone’s presence.

This is actually why I gave up supporting the bridge I wrote. I now have such a simple script running on my router which announces OH when I am/ I am not at home. It goes somethin like this

Hi @alex_bartis,

Very interesting, I did not know that, thanks.

I run pfsense so I should be able to do this, however this is very reliant on ones usecase. If you are always on your home network while at home this is great. I often take my phone off the network (pfsense being a bit “over protective” at times).

However I’m wondering how the geolocation worked for you? (as this still seems like the best solution in my usecase)
Is it just a matter of simplicity that made you switch to a WiFi based solution?

Hey guys,

im testing a solution with ibeacons at the moment. I’m not quite satisfied with it, but the approaches are quite okay.
I use a Raspberry Pi 3 with Bluetooth. For this I have made a ibeacon (https://waschto.eu/ibeacon-mit-geofency). On my Iphone runs the App Beecon which can call an url at the localhost. With this and a Script over the RestApi a Switch Item can be changed -> Presence.
If the connection to the ibeacon is lost, a pause can be installed which does not switch the absence directly. In addition, the whole thing can also be done so that the whole is only executed, the iphone logs in the Wlan … so can be prevented, that for whatever reasons from the distance something is switched (for example, the door lock is integrated)

Hi again everybody, I got to thinking :slight_smile:

Here is a very simple, but effective, presence detection via Apple HomeKit intergration. No scripting is needed.

  1. A always-at-home iPad or Apple TV is required as a host for HomeKit.
  2. Make a switch with the appropriate HomeKit tag i.e. [ Switchable ] https://github.com/openhab/openhab2-addons/blob/master/addons/io/org.openhab.io.homekit/README.md
  3. Install and configure the HomeKit integration (located under “add-ons → MISC” in the paper UI)
  4. Add the new OpenHAB HomeKit bridge to your HomeKit host (not your phone, like I did the first time :sweat:)
  5. Now simply make an automation rule on your phone to turn the switch ON when you arrive to you home and OFF when you leave your home.

I hope this might help anybody like me, who had the pieces, but didn’t think to put them together.

UPDATE; This method is random at best.

I have now tested it for little over a week with a telegram bot to notify me when the scene has changed.

The HomeKit method is dead to me, it haven’t detected me leaving or coming home even on´ce. This is straight up lazyness on apples part - they could do so little to make this work, but they haven’t.

This would be indeed a convenient solution.
No complicated MQTT magic, no operation of own server with security risks or paid hosted service.

The only downside the homekit binding is not working reliable and seems to be buggy at least with my experiments. Maybe I should give it another try.

What are your long term experiences with this solution?

I don’t have any long term experience just jet - I just started this a couple of hours ago - but I will let you know when I have had it a bit longer.

So far the HomeKit integration have worked just fine. However when i first tested this method my iPad (HomeKit host) was temporarily unreachable from my iPhone out in the wild. This corrected itself after a couple of minutes, but the switch had not switched to OFF. I manually set it to OFF, and when I got home it was correctly set to ON.

I don’t think the connection problem is on the side of HomeKit, its more likely my buggy PFsense firewall throwing a fit.

I am going to attach a Telegram Bot that tells me when a mode is switch, that way I can quickly notice if something issen´t happening.

I tried to use it but realized that to make automation work you have to have either a stationary iPad or an apple TV. Both of which I do not have.
So this easy solution is out of reach without further investment.

I am still wondering why myopenhab is not providing an MQTT server.
Or alternatively make the Rest API more flexible because there a lot of apps that can send POST to a server based on location. Unfortunately there is no possibility in myopenhab to process these.

It did work, but it had an impact on battery life. This does not :slight_smile:

Alex:
Your approach is working fine but a the timely accuracy is poor because the iPhone must be polled. Thanks for this. For me the benefit is no installation requirement on my family members iPhone :slight_smile:
But if you increase the polling frequency battery is of course impacted negatively.

I was replying to @GigabitGuy :slight_smile:

He asked how geolocation based on iCloud location worked for me. The fact is it had on impact on battery life. Using a script on the router to detect if the phone is connected to the network has no impact whatsoever. Also, it’s instant. Using iCloud is not.

I see @alex_bartis, I´m interested to see how the HomeKit method impacts the battery and how accurate it is on a daily basic. Although I´m hoping that Apple does some magic with it behind the scenes. I Guess we all can hope for a future where battery life is less of an issue :smile:

I’m testing presence, with the UBNT binding.
It’s working perfect right now.

When i arrive outside my house, it detects that i’m there 99% of the times, before i get thru the door.
UBNT releases a phone, after abut 15 minutes, so it don’t matter, if the phone jumps on and off the wifi. It’s still detected as being there.

The upside is also, that you get the best wifi ever, with the UBNT AP’s, and it’s not that expensive. I use the AP Lite AP’s.

A small note. The UBNT binding, i still in beta, but i think it’s already stable enough, to be released.

@GigabitGuy It should not impact battery life, more then homekit already does. Meaning that homekit is already enabled on your phone. running an extra operation should be unnoticeable.

@Robert_Jensen

Thanks for the info.

There are 2 questions:

  • When hopping on and off WiFi does not impact your presence, does the system notice when you leave the house and mark you as absent?
  • My house is not too big, yet WiFi is an issue, i have one Fritz!box in the cellar to connect to the internet, then one more on the first floor just running as Access Point and still need a repeater to get a proper signal in the bathroom, another Fritz!-AP is located on the ground floor. Reason is the structure of the ceilings (concrete) and having LOTS of WiFi-Networks in the neighborhood. Do you think that AP could improve the situation replacing the two Fritz-APs and the repeater?
  1. Yes after about 15 minuttes.

  2. Yes. You can setup as many ap’s as you want to, and they all act as one.
    As long as you can manage to get a cable between them.

/Robert
Sendt fra mobil enhed

My openhab2 installation is on a Synology DS916+ NAS. I never was able to make arp and hsping3 work on it. Right now me and my family are using Life360 app on our iphones. So i made life360 presence available to openhab2 and quite happy about it. You can see it on Life360 and MQTT if you like.

How is the flight with HomeKit method? I am thinking to try it if myself. What is your experience?