I upgraded my and my spouse’s phone from OnePlus 7 to Google Pixel 6 Pros. I’ve been using the same presence detection for quite a while but it stopped working after I updated the phones and the things and items related to those phones. It’s been working intermittently. I tried turning off Google’s “adaptive connectivity” and the VPN. Neither seemed to solve the problem. I can sometimes turn off and on the WiFi and I’ll see my device turn active but it doesn’t always stay that way.
The things show online but the switches sometimes turn to off even though the devices have not left the network.
Any thoughts?
Items are setup as:
Switch MarkHome "Mark is home" <presence> (Presence_Sensors) {channel="network:pingdevice:192_168_2_229:online" }
Switch SamanthaHome "Samantha is home" <presence> (Presence_Sensors) {channel="network:pingdevice:192_168_2_91:online" }
Thank you,
B34N
Solved:
Thanks to @rlkoshak I learned that Android 11+ has a WiFi setting to randomize MACs. Since I have multiple access points in my home, my phones would appear with multiple MACs and not always be seen through a ping. I went in and changed the WiFi settings on my phone for each of the WAPs to use the device MAC. I then recreated the things and adjusted the items. I did need to force the expiration of one of the DHCP leases on my router for everything to work.
Yes, simple enough. So I have confirmed that openHAB cannot ping those devices that are not showing active. Now I just need to figure out why not active. I’m suspecting it’s a problem with Android 12 or the phone settings even though both seem to be the same and one phone stays pingable for longer.
I have no knowledge of Android, strictly iOS here, but they may have been trying to improve privacy.
The docs suggest DHCPlisten as an alternative method.
I’m about to get a PIxel 6 Pro myself and my wife already got hers so I’m about to need to face this problem too. Things to be aware of:
As of Android 11 (I think) there is a privacy setting in the WiFi settings to enable/disable the use of a randomized MAC. Using a randomized MAC is turned on by default. When using a randomized MAC, any static DHCP leases you’ve configured will not work because your phone does not remain at the same MAC address.
For a long time indeed iOS will stop responding to pings even while the phone is in use. There is a way around that using an arping. Some Android phones also show the same behavior. Perhaps the Pixel 6 does the same? The network binding can be configured to do an arping instead of a standard ping.
I find that using the Android app’s “Send device Information” → “Wi-Fi name” (will update an Item you specify with the name of the SSID the phone is currently connected to) or using Tasker’s “SSID Near” settings to update an openHAB Item when you are near an SSID even if you are not connected to work far better than trying to ping the phones. Let the phones report when they are home instead of trying to ping them.
Yes, I see that this is set on a per network basis. I will change it to use device MAC when connected to any of my WAPs at home. I’m guessing I put a randomized MAC address that was reported when I setup the things.
Edit: Yes, that’s what happened. My phone was randomizing the MAC address for each of my WAPs. I went in and changed the WiFi settings on my phone for each of the WAPs to use the device MAC. I then recreated the things and adjusted the items. I did need to force the expiration of one of the DHCP leases on my router for everything to work.
This sounds like a more “elegant” solution. I’ve been using a version of the presence sample that you posted. Using the device location seems to be better because it will eliminate need for flapping and will likely prevent me from getting “Door has been opened” warnings when we open the garage door before the phone connects to the WAP.
i’m going to mark this as solved but will continue to look into the Tasker solution.