A smart home should know you have arrived without being told. Arriving on a pitch dark freezing cold November evening in Oslo, Norway loaded with carrier bags and all lights turning on when you approach the door. Wonderful idea.
So I dived into HC2 Geofencing. Only to find that a useful position update frequency (5-10 seconds) killed my mobile battery. Started thinking of ways your LAN could tell HC2 that the Master had returned, but found the limits of my network competence.
Now enter this clever French guy: https://www.domotique-fibaro.fr/topic/2613-detection-de-présence/ who came upon the idea of checking the presence of the MAC address of your mobile device on your LAN.
What he did was simply to make HC2 probe the presence of the mobile MAC address on the LAN ARP table. Frequently probing when not at home, less frequently when at home to ensure quick response when arriving at the door as well as reduce risk of "false departures" when at home. Seemed to work perfectly. The code is nicely written, clearly commented and implementation well explained. A true role model to follow for all the codeaholics out there publishing brilliant code that cannot be implemented or understood outside the immediate congregation.
Happy for a while, until I learnt that iPhone has the habit of turning off WiFi after screen closes. Not only is WiFi turned off, but the MAC apparently disappears from the ARP table. My house went into all lights off Absent mode and WAF nosedived....:-( Turned out to be a well known fact and commented on numerous web sites.
Here is my workaround: I kept Sebcbien´s presence/absence VDs running in its original form, but made my absence scene manual, with a 15 min delayed setting of a status variable to "Away". My thinking is that pushing a button when actually leaving is no big deal. And good security practise if and when I include a door lock in the system.
The arrival scene is however kept automatic and will respond within seconds once you return on the LAN. But you will have to activate the mobile screen to ensure quick WiFi logon and response. Not perfect, but quite good actually. Here are the elements:
(1) Sebcbien´s Virtual Device code above, version 2.10 (you might need to activate Google translate from French in the Domotique Forum). This VD code will set a 0/1 Absence/Presence variable. One VD and variable for each family member's mobile MAC address is advisable. You will need to modify in the code (a) The name of your absence/presence variable (b) Your mobile MAC address - to be entered in the VD address field (c) The ID numbering of your icons to be used. Seems I am the only person in the world not knowing that you can easily find this number by right clicking the icon and select "Inspect". Amazingly difficult to find this annoyingly simple procedure.
(2) The code has the ability to change the VD icon depending on Absence/Presence. Quite nice and useful.
(3) A (manual) "Leave" scene that when activated does the leave job, turns off lights etc and triggers a 15 min delayed second scene that eventually sets a status variable to "Away" once you are well away from your door. I had to set up a second scene, since a variable apparently cannot be set with delay in the block editor. This can probably be solved easily in LUA.
(4) An automatic "Arrive" scene that is triggered whenever one of the above mentioned VD variables is set to 1 AND the status variable is "Away". This scene will then turn on lights and devices and set the status variable to "Home".
This approach, although not as elegant as I would have liked to see this, will prevent the "Leave" scene from being triggered when iPhone goes to sleep.
I would be great to receive improvement proposals or alternative ideas