iphonedetect icon indicating copy to clipboard operation
iphonedetect copied to clipboard

Probe returning away on all iphones

Open mtthidoteu opened this issue 1 year ago • 2 comments

Hi, I am opening an issue as I can't find any reason this is not working and behaving as such: Config:

device_tracker:
  - platform: iphonedetect
    consider_home: 60
    scan_interval: 12
    new_device_defaults:
      track_new_devices: true
    hosts:
      iphone-one: 192.168.0.21
      iphone-two: 192.168.0.22
      iphone-three: 192.168.0.18
      ```
I am able to ping the devices from my Home Assistant installation which is not a different subnet but firewall rules are setup correctly. After enabling debug logs:

2024-08-30 11:14:17.323 DEBUG (SyncWorker_9) [custom_components.iphonedetect.device_tracker] Probe sent to iphone-one on 192.168.0.21 2024-08-30 11:14:17.326 DEBUG (SyncWorker_9) [custom_components.iphonedetect.device_tracker] Probe sent to iphone-two on 192.168.0.22 2024-08-30 11:14:17.327 DEBUG (SyncWorker_9) [custom_components.iphonedetect.device_tracker] Probe sent to iphone-three on 192.168.0.18 2024-08-30 11:14:17.341 DEBUG (SyncWorker_9) [custom_components.iphonedetect.device_tracker] Device iphone-one on 192.168.0.21 is AWAY 2024-08-30 11:14:17.341 DEBUG (SyncWorker_9) [custom_components.iphonedetect.device_tracker] Device iphone-two on 192.168.0.22 is AWAY 2024-08-30 11:14:17.341 DEBUG (SyncWorker_9) [custom_components.iphonedetect.device_tracker] Device iphone-three on 192.168.0.18 is AWAY```

Is there anything I am obviously missing?

mtthidoteu avatar Aug 30 '24 09:08 mtthidoteu

Having the same issue with the same debug information. HA can ping the devices, they are even on the same subnet and are having no issues communicating otherwise. Also have almost identical config in YAML and had been working fine until I recently updated HA to the following:

Core 2024.9.1 Supervisor 2024.09.1 Operating System 11.5 Frontend 20240906.0

bbiggscs avatar Sep 21 '24 12:09 bbiggscs

Hi,

I am able to ping the devices from my Home Assistant installation which is not a different subnet but firewall rules are setup correctly.

This integration doesn't "ping" (as in ICMP) the tracked device, it sends a message on UDP 5353 to the IP of the device.

mudape avatar Oct 12 '24 13:10 mudape

I also have the same problem. I'm new to this integration so I might be missing something else of course.

My config:

device_tracker:
  - platform: iphonedetect
    consider_home: 60
    scan_interval: 10
    new_device_defaults:
      track_new_devices: true
    hosts:
      xxx_iPhone_tracker: 10.0.1.30
      yyy_iphone_tracker: 10.0.1.31
      zzz_iphone_tracker: 10.0.1.32

Debug log:

2024-10-29 20:47:29.541 DEBUG (SyncWorker_63) [custom_components.iphonedetect.device_tracker] Device xxx_iPhone_tracker on 10.0.1.30 is AWAY
2024-10-29 20:47:29.541 DEBUG (SyncWorker_63) [custom_components.iphonedetect.device_tracker] Device yyy_iphone_tracker on 10.0.1.31 is AWAY
2024-10-29 20:47:29.541 DEBUG (SyncWorker_63) [custom_components.iphonedetect.device_tracker] Device zzz_iphone_tracker on 10.0.1.32 is AWAY

secz0r avatar Oct 29 '24 19:10 secz0r

Noticed the same issue with HAOS, iPhone was always away. However using HA container with macvlan networking it works fine. Not sure what's causing HAOS to not work but maybe this info might be useful.

mwolter805 avatar Nov 19 '24 01:11 mwolter805

Same here.

Kalekulan avatar Nov 21 '24 17:11 Kalekulan

Wondering if there might be a commonality in network hardware, HA installation type or OS version.

Installation Info

Here's is my setup, would be great if others can provide theirs so we can correlate similarities.

Network: Unifi Dream Machine Pro, U7-Pro access point, with HAOS on the same subnet as the tracked devices. HA Installation Type: HAOS is directly installed on a x64 machine. (not a virtual machine) HA Versions: HAOS 14.1, Core 2024.12.5, Supervisor 2024.12.0 Unifi Network Version: 8.6.9 iOS 18.2, MacOS 15.2.

Another Note

Recently tried a similar project intended to track devices on the network by pinging port UDP 5353 and tracking the connection with ip neigh show found it did not work either. This other project is similar but instead of being an HA integration it's a docker container using hping3 to generate the messages. Below is a link to the issue related to the other project. https://github.com/Passific/MQTT-iPhone-Tracker/issues/7

I was able to get the other project working and it is able to detect when devices connect to the same network. The key piece of info to the resolution was to track TCP ACKs from port 5353 of the device instead of sending UDP packets and reviewing the ARP table of the server.

Here's and overview of what I believe the issue to be

Symptom

ip neigh show command always shows 'STALE' for the tracked device regardless if the device is on the network or not. This was tested by sending a ping to the tracked device from a HAOS container and viewing the status of the connection using the following command.

hping3 -2 -c 3 -p 5353 <IP_OF_DEVICE> ; ip neigh show | grep <IP_OF_DEVICE>
...
<IP_OF_DEVICE> dev enp0s31f6 lladdr <MAC_OF_DEVICE> used 0/0/0 probes 0 STALE

The same command was sent from an LXC container on a Proxmox PVE host and the device was shown as 'REACHABLE'.

Possible Cause

It appears there might be something missing from the Buildroot config for HAOS or it could be a newer kernel in HAOS as it's using 6.6 and Proxmox is 6.5.

Most likely HAOS Buildroot is using Busybox and not iproute2. Buildroot often uses busybox to provide a lightweight replacement for standard utilities. The ip command in busybox may lack full functionality compared to the full iproute2 package.

Below is the kernel info for both: HAOS (does not work)

Linux version 6.6.66-haos (builder@0cb2e459fe37) (x86_64-buildroot-linux-gnu-gcc.br_real (Buildroot -g00e8f093) 12.4.0, GNU ld (GNU Binutils) 2.40) #1 SMP PREEMPT_DYNAMIC Thu Dec 19 11:32:53 UTC 2024

Proxmox LXC (works)

Linux version 6.5.13-6-pve (build@proxmox) (gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC PMX 6.5.13-6 (2024-07-26T12:34Z)

Recommended Fix

Change this integration to ping and check for TCP ACKs from the tracked devices. Appears this works fine on Buildroot machines.

mwolter805 avatar Dec 30 '24 16:12 mwolter805

Yeah, looks like some issue with the ARP lookup, however I can't reproduce :( Please test version 2 which uses pyroute2

mudape avatar Jan 13 '25 15:01 mudape

@mudape Tested the new version and it reliably detects the device's state although there is a one minute delay to detect away, which is considerably longer than before. I'll make a new issue regarding this to see if anything can be done.

mwolter805 avatar Jan 16 '25 19:01 mwolter805

Closing as related to release 1 and network. Please reopen or better, create new if problem still exists

mudape avatar Feb 01 '25 13:02 mudape