I have created a pretty solid wifi presence solution for when my phones connect to the wifi network, its very quick to update ST.
I use this alongside the ST app, Life360 & my own Tado presence device type, i use Rule machine to flip a virtual presence sensor when any of the 4 change state, this is a first past the post setup and it works really well, before i put this in presence was really an issue. this however always triggers when all the others fail to update (regularly) but the range of this is not very far, only within the wifi range (obviously!)
ive seen other solutions for DD-WRT, but these don’t work with the Newer Asus routers, RT-AC87U or Newer as the command to list mac addresses with the new 5G hardware no longer uses wl
ok so the first thing i did was install the latest AsusWRT Merlin for my router
then once installed i then logged into the routers web page and went to administration → System
on this page i enabled SSH and set both these options to Yes
then i saved and rebooted the router. once this is restarted you can log into the console via SSH
in the /jffs/scripts folder i created a new file called CheckIfHome with the following contents (this example is the file with the mac addresses and oAuth detail stripped out for my family, it is checking for 4 users, this example should be very easy to follow and customise)
you then need to type the following command to allow execution of the script chmod 777 /jffs/scripts/CheckIfHome
then just create the CheckUser Folder with mkdir /jffs/scripts/CheckUser
I then installed 4 Virtual Presence Sensors one for each family member from my Virtual Presence Sensor Device Handler
and then i installed my SmartApp that ties this together and recieves the http Get from the router (be sure to enable oAuth in the smart app)
I used then used the ST Mobile app to install 4 copies of this smartapp, one for each Virtual presence sensor.
once these have been installed you need to get the Application ID and Access Token for each app, this can be gotten from the location Tab, List Smartapps page in the IDE, just click on each of the smartapps you just created and get the following details. (sorry cant draw with mouse )
then just update the respective curl request lines in the CheckIfHome Script with these details, remember to change the url to https://graph.api.smartthings.com if you are in the US
last but not least we want to run this script every 15 seconds (well at least i do !)
so the last thing is to create the init-start script in the /jffs/scripts folder using vi with the code from
you then need to run chmod 777 /jffs/scripts/init-start
and now either reboot your router or just run the command ./init-start which will schedule your wifi check to be performed every 15 seconds.
this does work extremely well, you can see for troublehooting purposes at any time on the router who is home or away by just running ls -als /jffs/scripts/CheckUser this will show any users who are currently home as they will have a Home File, if they are away this file will be deleted.
its a bit long winded but i hope this helps someone out, it works great for me, and did i mention it is quick to detect users?