Good luck with that. I tried to do that once…
Good. We can use that. Add the following to your Person_x Items:
<[mosquitto:/presence/wifi/*-*-*-*-*-*:state:ON]
So every time the router sends a LastSeen message it will update the Switch Item to ON. since that happens every minute it will keep the expire binding from changing the Switch to OFF. 4 minutes after the last LastSeen message (if for some reason the disconnected event didn’t get sent) the Switch will go OFF.
This will be a problem no matter what I suspect.
Detecting iPhones on the network is a well known and difficult problem. When it goes to sleep it puts the device into a hibernation mode that makes it mostly unresponsive to network events. However, if you search the forum for “hping” you will see one way a lot of people have got around this problem with iPhones. The Network binding just added and arping feature that essentially does the same as the hping solution.
Personally, I use a combination of presence sensors in my system. I configured my and my wife’s phones with static IPs on the router. Then I use the Network binding to periodically ping them to see if they are present.
But the iPhone disconnects so I also use Bluetooth detection on a number of Raspberry Pis that I already have scattered throughout the house for other purposes using a script I wrote. Finally, I’ve added reelyActive to my Raspberry Pi 3 which also does BT device presence detection but in a smarter way. I’ve since replaced one of my old Pi 1s with a Pi Zero W so plan on adding reelyActive to that one as well and see if I can start to get some better resolution (e.g. tell which floor the device is on). That is a relatively low-level priority though.
BT works well for me because both my wife and I have a smart watch and my wife has a medical device always attached which also uses BT so it works well.
Anyway, I require at least two sensors to report a device as present to mark a person as present (BT can have false positives).