Iphone device tracker when they are on a different subnet

I had an issue using the otherwise fantastic iPhone device tracker integration.

My guests connect to a Wifi network isolated from the main “homies” network. They get a different IP from the range 172.16.0.XXX, where the home members get a 192.168.0.XXX. Classical security, but still, an issue for this integration is that it cannot detect phones sitting on another network than the one where HA is seated.

I created a simple bash script, running on my firewall/gw as a workaround, which send the udp:5353 packet, checks the arp table and post an update using MQTT, adapt to your needs.

#!/bin/bash

hping3 -2 -c 3 -p 5353 172.16.0.10  -q >/dev/null 2>&1

[[ -z `ip neighbor show | grep REACHABLE | grep "172.16.0.10 "`  ]] && guest_status="not_home"  || guest_status="home"

mosquitto_pub -h localhost -p 1883 -u [MQTT_USER] -P [MQTT_PASSWORD] -t homeassistant/phone_tracker/guest -m $guest_status