[RELEASE] iPhone WiFi Presence Sensor

community_driver

#1

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
  • Nokia 6
  • Note 9
  • S8+
  • MotoX4

Installation

  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"

[RELEASE] Combined Presence
Wait for Hubitat iPhone app, or use Life360?
Geo Fencing
Hubitat not displaying life360 presence correct
Presence detector
[RELEASE] Combined Presence
Mode Manager: Mode based on presence - Delay/Cancel
SSH Client
Most reliable presence detection
Startup questions
Geo Fencing
Community Device Drivers (FKA Compatible Devices Wiki)
Community Apps
[RELEASE] Web Pinger
Simple Power Outage Detector
Presence Governor
Alarm/New Build/HSM/Noonlight/Konnected
IPhone Presence Detection
App geofencing or presence devices?
#2

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.


#3

[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?


Use Locative for Presence
#4

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.


#5

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.


#6

Excellent!


#7

Confirmed, working on Android Pixel XL too.


#8

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


Will there ever be a solid presence option?
#9

Do you just put the ip of an Android phone?


#10

Yes. Worked on my Note 9 too.


#11

The iPhone version


#12

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).


#13

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.


#14

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.


#15

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


#16

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.


#17

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”.


#18

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:


#19

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


#20

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.