@Fuzzyligic@PerspectiveTransform
Mofied your script for clarity as well as to make it work with newer router. It is for 2 users, but can be expanded. Maybe you find it useful. This way to enter all info so if any errors there is only one area to correct. Just enter your Info in the required fields, including ServerURL (Ishow the US one). It’s been working properly for a few days now. Here it is
case “$macadresser” in $User1Mac)
User1=Home
;;
esac
case “$macadresser” in $User2Mac)
User2=Home
;;
esac
if [ “$User1” = Home ]
then
if [ ! -f $User1Tag ] || [ “$1” = “-f” ]
then
touch $User1Tag
curl $ServerURL$User1App$ServerURL2Home$User1Secret -k
fi
else
if [ -f $User1Tag ] || [ “$1” = “-f” ]
then
rm -f $User1Tag
curl $ServerURL$User1App$ServerURL2Away$User1Secret -k
fi
fi
if [ “$User2” = Home ]
then
if [ ! -f $User2Tag ] || [ “$1” = “-f” ]
then
touch $User2Tag
curl $ServerURL$User2App$ServerURL2Home$User2Secret -k
fi
else
if [ -f $User2Tag ] || [ “$1” = “-f” ]
then
rm -f $User2Tag
curl $ServerURL$User2App$ServerURL2Away$User2Secret -k
fi
fi
@NomadTech Thanks for your response. I have used the Device handler and Smart app from Fuzzyligic code repository, Admitting being very new to this, I created Oauth and applied it to the curl. I think this is where I am going wrong. Any help on where to pick the App id and access token would help.
I use Chrome with json plugin for properly formated display for AppID
Once you publish your app go to edit and enable OAUTH and click on it.
as @Fuzzyligic said, 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
Just follow his instruction at the beginning of the thread, except the IDE URL which is https://graph-na02-useast1.api.smartthings.com/ for US.
Login, go to MyLocations, click on SmartApps and click on yours. This is my screen
I have run into a wee bit of a problem using your respective smart app / code…, but first a bit of history.
I have a Asus RT-AC68U
I sucessfully set up @Fuzzyligic 's code to do wifi presence detection.
Just to re-iterate again, it works fine.
I then noticed my Android Note 4 device periodically falling off & creating issues for me. @chadly’s code to implement a delay was just the thing I needed.
What I then did was the following:
Kept @Fuzzyligic 's ORIGINAL asuswrt-wifi-presence.groovy; it is tied to my wife’s phone
Kept @Fuzzyligic 's ORIGINAL virtual-presence-sensor.groovy
Because @chadly’s smart app name is the same as @Fuzzyligic 's, I renamed it as such:
definition(
name: “AsusWRT Wifi Presence with Timeout”,
namespace: “chadly”,
I did NOT use @chadly’s version of check-home.sh on the router; after all, if it aint broke then don’t fix it!
I DID modify the CURL lines to reflect the new “AsusWRT Wifi Presence with Timeout” smart app’s Access Token and App ID.
— the CURL line for my wife’s phone points to @Fuzzyligic’s smart app
— the CURL line for my phone points to @chadly’s smart app
When testing the wifi presence now, the router correctly creates the presense files as it should/did.
However, the virtual presence sensor no longer updates in ST.
Logging reveals this error:
131e16b7-xxxx-xxxx-xxxx-d78f10825856 1:32:49 PM: error physicalgraph.app.exception.SmartAppException: Not Found
The curl line to hit my smartapp is slightly different than the original one. I changed them to POSTs instead of GETs and altered the path slightly. In retrospect, I probably should have left those alone to keep things more compatible.
Just change the CURL line that hits the “app with timeout” to POST and .../api/smartapps/../<APP_ID>/<home,away>. Check here for the full line.
I didn’t look too closely at your version of asuswrt-wifi-presence.groovy, but did immediately notice it used a different format of the CURL command.
Is your version of the Smart App DEPENDENT on the very specific formatting of the CURL line as found in your version of asuswrt-wifi-presence.groovy? Am I mistaken in thinking that using the original CURL format but just substituting for the new Access Token etc. as created by your smart app will not suffice and hence the error?
I have a Asus RT-N66u running on latest Merlin. I have followed the steps from fuzzy logic to install the ASUS wifi presence, Device handler and the smartapp as below,
once i have this configured in the smartthings , My presence checking script works fine, except for the curl.I am trying to run the curl from my ASUS router as a test before adding it to the script,
Connection #0 to host graph-eu01-euwest1.api.smartthings.com left intact
{“error”:true,“type”:“AccessDenied”,“message”:“This request is not authorized by the specified access token”}Kiran@Area51:/jffs/scripts#
I am not sure if this is something to do with the curl in the Merlin version in RT-N66u, or is it something I have overlooked when putting this together. Thought I will give one last try in this forum before I give up. Any help on this is highly appreciated.
Thanks for great guidance and it’s working well. I’m using my car’s WiFi to trigger garage to open or close. However it’s a time delay which is a but annoying. It takes up to 40-50 seconds to update presence. The user file in router is updated momentarily but there’s a noticeable delay in ST. How to speed up?
@Sajjad_Sarwar if the file is being created pretty much immediately, then the web request must also be created at the same time (this is provided you are using my code and not @chadly 's version as i haven’t looked into what his version is doing in regards to the timeout) if that is the case maybe the delay is occuring in your logic for the garage door if you are using CoRE…way to check is look at the live logging and see if the request is first being in a timely manner in ST. if so then troubleshoot further down the chain.
obviously wifi can sometimes takes a while to connect, but if youve already ruled that out by checking on the file creation then it must be further up the process where the delay is being introduced. but my advice is test and monitor each portion and it should become apparent where the delay is introduced as my experience is that when wifi has connected the whole recognition and web request being sent is done in a very timely manner, usually within 5 - 10 seconds
I did some more troubleshooting and the delay is the router (Asus RT-AC68U). Sorry for the misunderstanding. If I quickly toggle wifi on/off the router updates momently. Otherwise it can take up to 40-50 seconds.
I’m running your scripts. Only change I have made is in the CheckIfHome scripts where it looks for LAN, 2 and 5 GHz wifi.
Somehow we can make the init-script run often as every second?
@Sajjad_Sarwar forget about running the script every second, you cant runt he script at a faster interval than the script takes to run otherwise you will will exhaust threads and memory and your router will crash.
so if you run the /jffs/scripts/CheckIfHome script manually does this create the file and send the web request in a timely manner?
if so you need to look at your cron jobs.
if you run cru l you should have an output of multiple lines… I run mine every 15 seconds and my output fromt he command is as follows