[SOLVED] Iphone presence issue WIFI

Hi community.

I have setup my iphone with Network binding and works fine, apparently because, everytime is connected to the wifi , system knows there is someone at home. The problem is that the iphone when is locked, there is an update of the DHCP, and system thinks there is none at home. Iphone is till connected to the wifi but, in sleep mode, or locked or in inactivity period, it is like is not connected to wifi.

I have read some topics in the forum, and it seems that is not working properly this functionality, at least in IOS.

I got to avoid the “disconnection” modifiying the property of the “Pingable network device” the timeout and so on. With this method, work fine, because I do not get a disconnection after device is locked, but the issue is that whenever the device disconnect from wifi (when I am out of home), the system spend more time to realize is off, and not working properly.

I do not know if there is another way to get implemented this functionality with the network binding.

My router is speedport, so I can not use scripts in the router, to send it to OH.

Other solution, is to use presence sensor, but I would need to put one sensor in each room, kitchen and so on… :s

Thanks for your answers.

Get a proper phone. :wink:

1 Like

iCloud binding is pretty useful, in combination with network. Ie if the device is off the local network and 500m away is presence set to “away”

1 Like

Newer Android phones behave this way too.

There is an arping feature in the Network binding that works very well. See the arping configuration docs in the Network Binding and search the forum for “arping” and you will find several postings about how to tune it properly for iPhone detection. I know many ore using this configuration very successfully for iPhone detection.

As Dan mentions, the iCloud binding is also reliably used by many on this forum.

1 Like


I will read carefully the documentation, but I have already done before, but I am missing something.

It is mandatory to install the arping tools, right? to work properly with the Network binding?

Yes you must install the arping tools. And you need to work with the timeout parameters to get reliable detection which is discussed in the forum threads.

Something I am missing, I have installed arping, and I am modifying the timeout, but does not work properly.


Thing network:pingdevice:phone [ hostname="", port="0", retry="50", timeout="7000", refresh_interval="10000", use_system_ping="false" ]


Switch OUT_HOME "AWAY"   { channel="network:pingdevice:phone:online" }

At the end, when the phone enter in sleep mode, after the all retries and timeout, the status change to OFF

I have tried untill this setup:


I have typed this in terminal:

arping -c 1 -I eth0

When phone is up, I receive answer, but when is in sleep mode/locked I got:

ARPING from eth0
Sent 1 probes (1 broadcast(s))
Received 0 response(s)

I have read this topic: Network Binding - iPhone Presence Detection - arping Configuration question

And I do not understand the idea to modify the Timeout. It does not matter if OH detect the device off after 2 minutes or after 30 minutes, at the end will be detected as OFF when the device is conected to the WIFI… so this will not work…

I don’t use this for iPhone but I do know this. Hundreds of users are successfully using the Network binding with arping for iPhone detection. Beyond that I can’t offer technical advice as I don’t use it.

But I don’t think the Network binding uses arping alone. Back when we had to do this by scratch we used to have to send a special packet using hping3 first which forces the iPhone to wake up and then the arping catches the arp response from the iPhone after it is forced to wake up. Again, I’m not an expert but I think this is how it works. I think the Timeout parameter defines how long to wait for this special packet to be sent out again.

ok, this is the clue.

This is what I am missing. ok thanks for the answer. I will read carefully about it, and search info…

I’ve had pretty good luck using OwnTracks geofencing

The only time it misses is when my iPhone is under 5% battery other than that it’s been flawless

Thanks, I will have a look as well.

@grhosso I use a combination of OwnTracks, the Network binding, contacts on all exterior doors and a few PIR’s that also operate the lights.
Once a phone is detected, or a PIR trips my rules assume someone is home until a door is opened and closed. Then after a delay the rules check for a phone or PIR trip before setting the away state. I have a series of OwnTracks geofences that regulate the HVAC setpoint such that the temperature is normalised by the time I return home.
Recently I’ve found that I have to ignore OwnTracks updates when I am at home as iOS seems to give out incorrect locations when the phone is sleeping.
Someone once referred to this in the deep and distant past as a “Bee in a Box” scheme, basically meaning the Bee is always in a box until the door is open, after the door is closed you look to see if the Bee has remained


I guess that OwnTrack works with MQTT right?

Its got its own binding, but yes it works over MQTT. A little fiddly to get set up, but worth it in the end. The community over there will help as long as you’ve had a go at following their instructions first

cool. I will have a look. Interesting. A combination of geofence and wifi, could be enough. I have a magnetic sensor at the main door and I will use them for the Presence in combination as well.

Regarding to the Networking binding, I have found this topic: iPhone Presence Detection with hping3 and ARP but it is from 2015. Is it working this procedure? I mean, I need a script to wake up my iphone every minute when is in sleep mode, otherwise, OH sees the iphone OFF and it seems that none at home.

The phone does wake up from time to time, maybe every 20 minutes when not in use and the network binding is very fast at detecting this, iPads work the same. Repeatedly waking it will shorten your battery life considerably. If you are happy to take the battery hit I’d give the procedure a try. I did look into the icloud binding as an OwnTracks replacement, but the location seemed to be out of date due to needing the phone to periodically wakeup, send its location to icloud, then the delay before the binding got the location from iCloud. Even OwnTracks can only wakeup periodically to send its location so I have more geofences than strictly necessary to ensure the “coming home, tweak the heating” messages get through.
Use the phone as a steering mechanism would be my suggestion, you could use bluetooth beacons attached to your keys if it must know you are there, and for this I’d recommend checking out https://www.happybubbles.tech/presence/detector but it will hammer your MQTT server several times a second, as it will detect ALL bluetooth broadcast messages and the Tile Bluetooth tags stop broadcasting when they connect to the app on the phone. Bluetooth beacons are very short range and have no broadcast security.

I understand. OwnTracks will shorten the battery as well, I guess you need to have running all time the location setting? or only while using the app?

They only recommend real time when using the app, the rest of the time I have it in “significant changes” mode where it uses Geofences and I haven’t noticed it draining my battery. Maximising battery life is why I don’t let anything continually use location services

1 Like

This is what I use and it works. However, this script is exactly what the Network Binding arping configuration does. The only reason I use it is because arping was not available in the Docker Image until a few weeks ago and I’ve not upgraded yet.

MQTT was designed for use in an industrial SCADA context by the oil and gas industry. Given adequate resources, you would need something closer to hundreds of messages per second before you start to see problems.

I am using this script, and when I ejecut the script, work pretty fine:

  • when phone is conected to WIFI, I get devices detected.
  • when is not conected to wifi, device is not detected.

but within OH, always show me ON states even with the phone disconected from WIFI…, it seems that the rule does not work properly.

for i in `echo $DEVICES`; do
    # Change dev and eth0 if needed
    ip neigh flush dev eth0 $i
    hping3 -2 -c 10 -p 5353 -i u1 $i -q >/dev/null 2>&1
    sleep 1
    # Only arp specific device, grep for a mac-address
    status=`arp -an $i | awk '{print $4}' | grep "..:..:..:..:..:.."`
    #A mac will be 17 characters including the ":"
    if [ ${#status} -eq 17 ]; then
        echo "Phone $i is detected!"
        echo "Phone $i is not present"

This is my rule file:

```var Number IphoneCounter = 0
val Number MaxCounter = 18

rule "Execute script IphonePresence"
    Time cron "0 * * * * ?"
    var String IphoneExec = executeCommandLine("sudo@@bash@@/opt/IphoneD.sh", 5000)

rule "Determine presence Iphone"
	Item Iphone received update
then {
	if(Iphone.state == "OFF") {
		IphoneCounter = IphoneCounter + 1
		if(IphoneCounter > MaxCounter) {
			IphoneCounter = 0	
			logInfo("RULE","Iphone  counter reached threshold and sent command OFF. Counter set to 0")
		else {
			logInfo("RULE","Counter Iphone threshold not yet reached. Counter set to " + IphoneCounter)
	else {
		IphoneCounter = 0
		logInfo("RULE","Iphone_Sw received command ON. Counter reset to 0")