When you are at home, use a PC browser to log into your router, and poke around the pages until you find a page showing what devices are connected to the router. Ideally, the page will list the MAC address of your phone. (so there is no false alarms) If you can find a specific page devoted entirely to your phone’s connection, even better! Pay extra attention to the keywords found on that page when your phone is found. Then turn off your phone and refresh the page to see what keyword has changed. You will need this info for the piston. (it is also a good way to make sure you have selected the right device from the list)
Once you found a webpage that works, and it updates correctly when you turn your phone off, copy that exact webpage, and paste it into your webCoRE piston something like:
Make a GET request to http://192.168.x.x/fullAddressHere with type FORM;
Set variable {deviceFound} = {contains($response,NameOrMacOrKeywordHere)};
IF {deviceFound} is true
THEN turn on simulated switch 'AtHome'
ELSE turn off simulated switch 'AtHome'
That is the basic concept. A few key points to keep in mind:
- Replace ‘NameOrMacOrKeywordHere’ with the exact wording that can only be found on the webpage when your phone is connected to the router
- My router only updates that page every 2-3 minutes when a signal is lost, but YMMV
- My piston runs every 3 minutes. (it is reliable, but not instant)
- I had to tell Android to not put WiFi to sleep (or the router will think I have left)
- If you reboot your phone, there may be one trigger when the router can’t see it
To solve this last (minor) issue, I have made my piston a bit more complex. Now it has to have two ‘false’ reads in a row for it to trigger I have left.
To be honest, the hardest part of this process was finding the right webpage. My router has over 40 main pages, but about 150 more sub pages. It was on a tiny sub-page that I ended up going with. For me, it was:
Settings > LAN > Status > Active Devices > Find my phone in the list > Device Details
(but every router is different)