How I Use My iPhone to Track Family Presence in Smart Home

Hey everyone, I wanted to share a clever workaround I discovered for tracking family members’ presence using our iPhones. I stumbled upon this idea after reading about others’ struggles with detecting devices via Wi-Fi due to battery-saving features. Here’s how it works and what I’ve learned along the way.

First, I realized that even when my iPhone is in standby mode, it still receives emails and messages, which made me think about how it interacts with the network. I decided to do a port scan on my local network and found that both of our iPhones were actively listening on port 62078, known as the ‘iTunes port.’ Intrigued, I wrote a simple Perl script to check this port periodically.

The script uses a timeout of 5 seconds to connect to the port. If it successfully connects, it means the phone is present. I’ve been running this script for about 38 hours now, and it’s been remarkably consistent in tracking when our phones come and go from the house. However, I’m a bit skeptical because port numbers can change, and it might just be a coincidence that both phones are on the same port right now.

Here’s the snippet of the Perl code I used:
perl
sub IsThisPersonHere {
# ($name)
$found = 0;
open(IN, “timeout $TIMEOUT_SECS telnet $PHONEIP{$_[0]} 62078 |”);
while (chop($line = )) {
if ($line =~ /Connected/) {
$found++;
}
}
close(IN);
if ($found > 0) {
return ‘Yes’;
} else {
return ‘No’;
}
}

I’m excited to share this method, but I fully expect it to stop working as soon as I hit submit! It’s been a fun project, and I’m curious to see if others can replicate this success or if there are better ways to achieve the same result. If anyone has tried something similar or has improvements, I’d love to hear about it!

Happy tinkering!