Working Iphone wifi presence locator

Of course…my fault…thanks!

no Problem :wink: Does it work?

Nope! :wink:

It seems that it’s working from ON -> OFF but messes up the other direction OFF -> ON (results not reliable). But I haven’t had much time to dig deeper into this…

Thanks for your script Björn.
Works fine for me.

Sometimes it takes more then one 60 seconds cycle but thats no problem.
I made the other rules to wait 5 minutes before changing something when no ones home.

Cheers
Michael

OK, it only worked yesterday.

Today i did some tests and randomly checked my UI.
When my girlfriend went to work her phone stillt showed as online.
Even when looking into the ip neigh show IP_ADRESS her phone was still there.

So i tried to play around with the ip neigh flush IP_ADRESS.
The first tries went pretty well but soon after the phone didn´t get back.
It´s connected to the wifi but it still says “FAILED” when using ip neigh show IP_ADRESS

It takes up to 5 minutes to get visible for ip neigh again.

Cheers
Michael

please check this solution:

https://community.openhab.org/t/best-presence-detection/11966/38

Hi Jonathan,

I know this is an old thread but I’ve been trying to implement your home presence logic in openhab 2 using the exec binding and a bash script. I have it working for the most part except for the hping3 part.
For testing the hping3 command, I do the following:

To monitor my iphone connectivity, I use the ping output. Then I run the hping3 command as per your instructions:

hping3 -2 -c 10 -p 5353 -i u1 xxx.xxx.xxx.xxx

I get the following output:

HPING xxx.xxx.xxx.xxx (en0 xxx.xxx.xxx.xxx): udp mode set, 28 headers + 0 data bytes

--- xxx.xxx.xxx.xxx hping statistic ---
10 packets tramitted, 0 packets received, 100% packet loss
round-trip min/avg/max = 0.0/0.0/0.0 ms

And ping output shows no connection with the iphone after the command is run.
The hping3 output also looks like 0 packets were received … so did it fail?

What am I doing wrong?

Thanks,
Randy

Made the same experience. In fact none of my devices on my network respond to this request. It is somewhat better if I allow for more time (parameters are set for 1millsec) and responses from some other devices trickle is but response time is very slow (500ms or so) but nothing with an iphone7 …
Hope someone knows more

hping just wakes the phone. Afterwards you need to check for the mac with arp.

Thanks @normaniac
I only looked into the details of hping3 because the script [edit see above with arp and everything] reliably and consistently misses the presence of the iphone in our house. MAC capitalized or not (and of course it is a fixed ip-address), it reports “absent”, wether the iphone is sleeping or actually not sleeping. Not sure what I am doing wrong here.

[Second edit, the script way above had some typos (oh, solutions are often simpler than it seems), here the script that works for me:

#!/bin/bash
declare -a DEVICES
sudo hping3 -2 -c 10 -p 5353 -i u1 192.168.XXX.XXX -q >/dev/null 2>&1
DEVICES=`arp -an | awk '{print $4}'`
CHECK="XX:XX:XX:XX:XX:XX"
if [[ ${DEVICES[*]} =~ $CHECK ]];then
        echo "Present"
else
        echo "Absent"
fi

I am having trouble with this script to reliably detect presence, not because the script doesn’t seem to be working, but that arp does not seem a good indicated of an iphone being on the network. For instance, after my phone is off the network, it remains in the arp cache for a long time (hours). Then, when it come back on the network, it doesn’t reliable get updated in the arp table on my computer. Is this normal?

Thanks
Jeff

Did you try this modification?

Edit: see thread above for where to put in the script

Operator error here. The hping3 command wasn’t installed, but the script was directly output to /dev/null so I never saw this.

Thanks for help.

Hi, I was wondering if instead of using a hping3 script to wake the iPhone if we could use the tcp/udp binding ? I’m not on linux and hping3 is hard to install on Mac… also I prefer to have all my thing running in openhab with no external script

The discussion surrounding iPhone Presence Detection has been continued over here:

Hey all,
I have extended the network binding to be able to use arping. Additionally I send an empty packet to udp port 5353, as suggested here in this thread. I do not own an iPhone though, so cannot test if it actually works. The device presence detection for my android 6 phone works now, thanks to arping.

The pull request:

3 Likes

Jar available at: https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.network/2.2.0-SNAPSHOT

1 Like

The binding update is merged. Can people with iPhones tests the presence detection and report success / failures please :slight_smile:.

The new version is only available in a 2.3 release and snapshots.

Cheers David

Hi!

I’m a total noob. I’m trying to get presence working with my iPhone via wifi instead of geofencing.

I can’t get it to initiliaze.

I ran the below commands

bundle:install https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.network/2.2.0-SNAPSHOT
bundle:start 237

Monitor the location of one or more of your Apple devices in a single iCloud account. They are managed by a single root VERA device with a single polling loop.
iPhone Support Number