Ping on iphone unstable

when I ping my iphone (tel jpp) it is sometimes unreachable. while another android phone works without problem tel fabienne) . It must come from iphone, what should be configured on the iphone so that it always responds to the ping?
However, when I do it manually, it responds well


thanks.

From what I know, this is when the iPhone goes to sleep and saves battery. I donā€™t think thereā€™s anything you can do about it.

In my case, where I do this, I only record the state as off if it couldnā€™t ping over a duration of 5 min (it pings every 30 sec). This is very long, but for my application itā€™s ok.

You can look into other mechanisms of device tracking, like Bluetooth or looking at registered devices on the network (using the ARP tables, which is what some of the network equipment device integrations would do).

3 Likes

I have had reasonable luck with this on HassOS on a rPi4. Uses a similar thinking. Need your own IP; and ensure this remains static in your router; and turn off the iPhone ā€œPrivate Wi-Fi Addressā€ security for the SSID.

command_line:
  - binary_sensor:
      name: iphone_ping
      command: >
        IP="10.0.0.34"; 
        ping -c 1 -W 1 $IP > /dev/null 2>&1 && echo success || 
        (printf "Steve Jobs" | nc -u -w2 $IP 5353; ip neigh show nud reachable nud delay | grep -i "$IP" > /dev/null 2>&1 && echo success) ||
        (printf "Steve Wozniak" | nc -w2 $IP 62078; ip neigh show nud reachable nud delay | grep -i "$IP" > /dev/null 2>&1 && echo success || echo fail)
      device_class: connectivity
      payload_on: "success"
      payload_off: "fail"
      unique_id: "binary_sensor_iphone_ping"

It is a common problem for many modern phones and Android is not exempt from this, especially not if it is a Samsung Android.

Ping is probably the worst solution, because it will wake the phone up and increase battery drain.

The integration is not better really.
It actively asking the phone to reply and there also waking it up.
With the 12 secs update interval it is keeping the phone awake, even though you might not see it.
If the ARP timeout in your router can be changed, then this interval can be increased.

The best way would be if the ARP timeout can be changed and set to something like 5 minutes, if that is low enough for you.
The 5 minutes timeout means the phone will wake by itself and update the entry before it times out, so there is no active pulling the phone.
The ARP table can usually be extracted by SNMP, which is a standard protocol that is available in nearly all management software, including HA and Node Red.

1 Like

Not much disagreement, but the thought was this is ā€˜at homeā€™ and battery drain isnā€™t normally a huge concern. The ping on an iPhone doesnā€™t actually wake the device up and frequently it makes it the ā€˜Wozniakā€™ before finding it in the IP tables. The good news is it doesnā€™t have many (if any) false positives and is extremely fast when moving off the network. I did Bluetooth scans at one point, and those are worse on battery drain from my results.

The most optimal regarding battery drain is probably the companion app since it only requires one send from the phone to HA.
Then the phone can go to sleep and nothing that requires the battery will happen untill the phone disconnects from the WiFi

1 Like

ARP table takes the least drain on the battery, but the it means you can not really do lower intervals than what the phone normally have of intervals to wake up and send stuff.
ARP table done that way is totally passive and just catches the normal operation of the phone on the network.
This only works locally though and require you can read the ARP tables and maybe also adjust the timeouts (my router had ARP timeouts set to 4 hours as standard.)

The companion app just works and provide a broader service for detection, like also detecting IP addresses, SSIDs, geolocation among other. It is an active detection form though.

1 Like

The WAF is in play here. Any attempt to install one more ā€˜of my projectsā€™ on her phone and it will be another expensive apology.

I canā€™t say if itā€™s active or not, but since it even can report you as on the network even when the phone is turned off (falsely though) then I highly doubt ARP can do it more efficient

if you can control the ARP timeout on your router, then ARP will set your phone entry to stale after the timeout where no packets have been seen.
The ARP table is managed by the network gear and therefore independent of the phone.

I actually use several detection technics on my set up and the ARP table lookup is the one I put the most reliance on.