[UPDATED] iPhone WiFi Presence Sensor

https://github.com/joelwetzel/Hubitat-iPhone-Presence-Sensor

iPhone WiFi Presence Sensor for Hubitat

A virtual presence sensor for Hubitat that checks if an iPhone is on the WiFi network.

Note: iPhones can put their WiFi to sleep, so you should not use this as your only way of detecting presence. However, it can be used to augment other presence sensors. Interpret results this way:

  • If this sensor shows "present", the iPhone is DEFINITELY present.
  • If this sensor shows "not present", the iPhone may or may not be present. We don't know.

Compatibility

I only have iPhone devices to test with, but other users have reported it working with the following Android devices. I cannot provide support for Android myself though.

  • Nexus 5x
  • Pixel XL
  • Pixel XL2
  • Pixel 3XL
  • S9
  • S8+
  • S3
  • Nokia 6
  • Note 9
  • MotoX4
  • Moto Z2play
  • Amazon Fire 7 tablet (2019)

Installation

IMPORTANT: If you update to iOS 14, by default it has a feature that randomizes your IP address. This will break this presence sensor. To fix this:

  • Go into your Wifi settings
  • Choose the settings for your home network
  • Turn OFF the "Private Address" feature

The best way to install this code is by using Hubitat Package Manager and then skipping to step 6 after installing the package.

However, if you need to install manually:

  1. Open your Hubitat web page
  2. Go to the "Drivers Code" page
  3. Click "+ New Driver"
  4. Paste in the contents of iPhoneWiFiPresenceSensor.groovy
  5. Click "Save"
  6. Go to the "Devices" page
  7. Click "+ Add Virtual Device"
  8. Set "Device Name" and "Device Network Id" to anything you like. Set "Type" to "iPhone Wifi Presence Sensor".
  9. Click "Save Device"
  10. On the device list, click the name of your new sensor
  11. Set "IP Address" to the local static IP address of the iPhone.
  12. Click "Save Preferences"
24 Likes
[RELEASE] Combined Presence
Wait for Hubitat iPhone app, or use Life360?
Geo Fencing
Presence detector
Hubitat not displaying life360 presence correct
[Beta] Unifi Wifi Presence
Best way to set modes when presence doesn't work
Geofence says I’m out of the zone when I’m not
Presence Using IFTTT Wifi
Presence by ping?
Nest Lock? Smart Locks in General?
After a week or so I start getting database errors
Should I pull the trigger on Hubitat?
Geofence says I’m out of the zone when I’m not
Mobile App Discovery
Community Device Drivers (AKA Compatible Devices Wiki)
Phone Not Triggering Away / GeoFence Issue
Simple rule not working.....frustration
Life 360 vs Hubitat presence
Erratic Presence
Help: Advanced Mother-In-Law Comode Mode (Bidet Presence Detector)
Rules Based on MAC or IP Address LAN Presence
Geofencing not workin
ARP Presence Sensor
Presence Governor
Linksys mesh as a presence sensor?
Geofencing reliability
[RELEASE] Web Pinger
Hubitat for AUS/NZ Chat
Hubitat for AUS/NZ Chat
Trouble with Telnet
Options to set HSM to Home / Away?
What to do about when Housekeeper arrives?
Cleaning lady - help with a rule
Circle of geofence
iPhone presence sensor
IPhone Presence Detection
Presence Governor
Simple Power Outage Detector
[RELEASE] Combined Presence
Alarm/New Build/HSM/Noonlight/Konnected
App geofencing or presence devices?
Mode Manager: Mode based on presence - Delay/Cancel
SSH Client
Most reliable presence detection
Startup questions
Life360 Location issue
Community Apps
[RELEASE] Web Pinger
Geo Fencing
Device Up \ Down using Ping
WiFi Connection along with Geofencing
Hubitat app presence detection problems
Lutron App Presence Geofencing
Presence detection not working properly
Bluetooth presence detection using a PI zero
[RELEASE] Alpha WyzeSense Integration
Presence is almost perfect... almost
Fing network tool
Add Xbox as a device and notify if turned on

Just curious .... what makes this specific to iPhones? It looks like it checks for a device's (specific IP) connection to the WiFi network. Is there some reason this would not work for an Android phone .... or a laptop .... or any other mobile WiFi device? Unless the responses expected are iPhone specific ... I thought this may work any mobile WiFi device with a static (or permanent DHCP lease) IP. I'll try that out when I get home ... but thought I would ask first.

Thanks.

[UPDATE] I just saw your other post:

I think that will do what I was thinking about and this one may be specific to iPhone?

Yeah this is specific to the HTTP response codes and statuses that the iPhone returns. Other devices such as Android phones MAY return the same responses. But I don't have one to test.

The other device handler tries to do an HTTP GET and looks for a status code 200.

It worked on my Nexus 5x. It showed present when i was connected to my wifi. Then I turned my phone off and it showed not present.

Excellent!

Confirmed, working on Android Pixel XL too.

1 Like

My S9 works and looks like my wifes nokia 6 does as well!

Do you just put the ip of an Android phone?

Yes. Worked on my Note 9 too.

The iPhone version

Seems to work with an iPhone Xs Max and a Samsung Galaxy S8+. Both show ONLINE when they are active and go OFFLINE soon after any phone activity stops.

I have to think about any use for this? As you stated ONLINE is definitely present, but OFFLINE really doesn't provide any useful information (it might be present, or it might not be).

It's interesting that the phones are behaving differently. I've been watching mine all day (it's an iPhone SE if that matters) and the presence sensor only goes OFFLINE if I turn on airplane mode or leave the house. I wonder if I have a ton of apps constantly requesting updates, so it's just never going to sleep. Hard to know.

What I've done with this is basically make composite presence. I have this as a presence sensor, and I use the Alexa app as another presence sensor. Then if either of those are present, I have rules that set a "combined virtual sensor" to present. That way if Alexa doesn't detect my arrival fast enough when I drive up to the house, the phone will at least connect to wifi when I get in the driveway.

It could be something to do with “location services” you have enabled more than just the apps themselves.

Do have the location services toggle switched to on and any app set to “always”? I’ve noticed that it seems to keep the phone more active even if it locked.

Yes, I do have "Always" for some apps, such as Alexa.

I can’t be certain, but I think this and possibly “background data” are the two biggest things that keep an iPhone from sleeping. But I’m no expert.

My assumption is that if you have “location services” on that it won’t let the phone sleep completely if something is set to “Always”.

Who doesn’t have at least one app with always on? For 99% of end-users this will work without ANY device prep. Meaning once the device hits your network, you have a reserve IP and then can create a presence device for that phone. This is a HUGE benefit especially if you want to do something cool for guests who are staying longer than anticipated and can modify rules and routines simply based on if those guests are present at your home.

THANK YOU @jwetzel1492 for creating this! You have solved the last puzzle for Presence for me. Now be careful as the HE team may permanently borrow this for additional presence capabilities like they have with @Cobra’s many app contributions. :stuck_out_tongue_winking_eye:

2 Likes

Great app! But now that it works with Android phones too I would like to formally ask that you change the name! :grin::grin:

Also, one other small request. Please add a switch to turn off the logging.

Thanks

3 Likes

I have a Huawei (android) but it does not appear to be working.
Can the android users out there confirm how they configured the device.
Is it just the ip address. 192.168.0.xx?
I've tried various combinations with no joy.