Check if iPhone is available in local network even if in sleep
nmap it is possible to check if an iPhone is available in the network even so.
At least execute 3 times following:
sudo nmap -PO -sU -p5353 -Pn <ip-address> | grep "1 host up" | wc -l
The best way is to regularly do this UDP ping and then e.g. if the phone doesn't reply even after
x minutes it is set to be away. This is handy for presence detection in smart homes.