[UPDATED] iPhone WiFi Presence Sensor

Here’s the thing: the Hubitat OS only invokes parse() in a device driver if it has received a message through the z-wave or zigbee stack. This is not a a-wave or zigbee driver, so I have no idea why it’s receiving messages. (Unless newer versions of Hubitat are now invoking parse() for new reasons?)

1 Like

An app or parent device could also potentially call the "parse()" command... :thinking:

This is a bit odd, since the user removed the device and then re-added it. Unless of course they also added this new device to all of the same apps that the old device had been a part of?

Yikes! I hope no other apps are trying to invoke parse on this driver. It’s a sensor, not an actuator. :grimacing:

Also does it for telnet, raw, and websocket IRRC.

1 Like

The parse() method will also catch traffic sent to port 39501 if the device's DNI matches the MAC address or IP address (in hex, no separators) from the sending device. But looking at the code for this driver, I don't see anything that sets the DNI to one of these, nor do the instructions say to, so it's likely just the default GUID Hubitat generates for new virtual devices that shouldn't match any of this. And, of course, you'd need the thing to be sending data to the hub, and an iPhone seems a particularly unlikely culprit (I guess I don't know how the Hubitat mobile app works, but this doesn't seem like that would be it...).

Still, I suppose, one more thing that could be checked--along with the "In use by" list in case some app might be trying to do this for some reason directly on the device (very unusual, child devices excepted).

1 Like

This driver makes a lot of errors on the 'iPhone SE2' and works very well on the 'Galaxy S10E'.
How can I use it well on my iPhone?

If you start by posting a screenshot of the errors you see in the hub logs, that would help.

Edit: or did you mean “it doesn’t work very well” on your iPhone SE2?


They're in the same seat, but they go out and come in and they change repeatedly.

Is the phone awake or asleep while this is happening? Low power mode on or off?

Probably not the issue, but just to confirm. Is “private wifi address” turned off in the iPhone’s Wifi connection settings?

1 Like

Under the same conditions, different results are repeated, so it seems that it is not a problem with phone settings.

I’m not quite sure I understand your reply.

But in the virtual device’s settings page, what is the timeout setting?

2 Likes

I suggest increasing your timeout to at least 10 minutes, like in my screenshot.

4 Likes

iPhones like to conserve their battery life when not in use, by temporarily turning off their WiFi radio for about 9 minutes. They then reconnect, check for any updates that may have been missed during that time, and then repeat that cycle.

This was discussed earlier in this thread

Thus, it is 100% normal for this driver (with a timeout less than 10min) to report Arrived and Departed when an iPhone is in your house, but idle. Using a timeout of at least 10 minutes, as mentioned above by @marktheknife, should help to alleviate this issue, if this is your only method of determining user presence. Many people use this driver in combination with other methods. Personally, I simply use the "Locative" geofencing app on my iPhone as it works very reliably, is free, respects privacy, and hardly uses any battery.

6 Likes

Thanks for elaborating, @ogiewon :slight_smile:.

@jw970065 you should not use only this method for determining arrival/departure, since as @ogiewon explained, the behavior you’re seeing is expected and mostly an unavoidable artifact of how iPhones automatically manage power usage while asleep.

As it says in the OP:

The developer of this driver also wrote an app that can combine more than one presence device, it creates a new virtual device that can be used for much more reliable presence-based notifications or automations.

If you don’t care at all about how long it takes for your phone to show as “departed” using this driver only, you could set the timeout to something very high like 15-20 mins. That might work around the issue. But like @ogiewon I also use other solutions like Locative, which is a separate iOS mobile app but can be integrated with Hubitat.

6 Likes

Thank you for the good advice. I'll try changing the setting.

1 Like

Thank you for the good advice.
It would be great to combine and operate various things.

hello, smallest timeout is 1 minute before showing the device offline, does anybody know what needs to be changed in the code to lower that? i need it to start my surveillance camera if electricity is off and i'm using this to detect the power surge but i need it faster than 1 minute.
what needs to be changed in the code to mark the device as not present in 10 seconds?
thanks
using 0.1 doesn't seem to work

In the code, you’ll find the following section

    if (enableDevice) {
        runEvery1Minute(refresh)		// Option 1: test it every minute.  Have a 10 second timeout on the requests.
        state.triesPerMinute = 1

	    //schedule("*/15 * * * * ? *", refresh)    // Option 2: run every 15 seconds, but now we have a 10 second timeout on the requests.
        //state.triesPerMinute = 4
    }

Simply comment out the first option and uncomment the second option.

    if (enableDevice) {
        //runEvery1Minute(refresh)		// Option 1: test it every minute.  Have a 10 second timeout on the requests.
        //state.triesPerMinute = 1

	    schedule("*/15 * * * * ? *", refresh)    // Option 2: run every 15 seconds, but now we have a 10 second timeout on the requests.
        state.triesPerMinute = 4
    }

i've already set it up like that, when is present it sees it very fast but after is not present it takes about 1 minute, i need in less than 10 sec to detect it not present

1 Like