[OBSOLETE] ASUSWRT Wifi Presence

I have everything set up – it works perfectly – THANK YOU STUART!!!

One – possibly stupid – question. Is there a way to have this work if I am on my extended network?

This is the problem I have. While it works great, if I move to the rear of the house, I connect to my other access point so therefore I can’t use this as reliable primary presence sensor. However, I do have it as backup in Rule Machine if my wife’s other presence sensors aren’t around and the WW-DRT senses her around, it works to change her master virtual presence sensor.

One other question - anyone know how can I set the router script to remove my presence only when my phone’s MAC address isn’t found for X time (say 30 minutes)?

my solution creates a file when the phone is found on the network, so the only thing i can think is that you do a touch on that file when your phone drops off the network so then the modified date is different to the create data and you check this timestamp only when the created and modified dates don’t match and when the that time is greater than 30 mins the script sends the http request and then deletes the file. if that makes sense

StartTime=$(date +%s -r Name_of_File )
EndTime=$(date +%s )
if [ ($EndTime - $StartTime) > 1800 ]

Thanks, @Fuzzyligic! I was able to get this working with a few modifications. My router, Asus RT-AC3200, doesn’t support qcsapi_sockrpc, so I had to adapt @PerspectiveTransform’s change to work with mine:

 macadresser="`wl -i eth1 assoclist` `wl -i eth2 assoclist` `wl -i eth3 assoclist`"

Once I did get it working, I also was having problems during the night where the router would periodically detect that my android phone was disconnected from the wifi, but then less than a minute later, determine it was connected again. This would mark me as away and then immediately present again in SmartThings causing all kinds of havoc.

I updated the app to take a timeout so that once the router says you are away, the app will wait that amount of time before actually marking the presence sensor as away. If the app receives a present notification within the timeout window, it will never mark you as away.

For anyone else having the same problems, check out my modified code here.

2 Likes

Good idea with the timeout. I don’t get the issue but would solve the away/home flap when I reboot my phone or switch WiFi network from 5ghz to 2.4ghz. Thanks for sharing

Help!

I’ve just bought an N66U and installed Merlin firmware. Installed the script, the device handlers and smartapp - but when I try to create an instance of the SmartApp in the ST app I get as far as choosing one of my virtual presence sensors, give it a name and select all the modes - and then “An expected error occured” in a red error message appears. Won’t go any further.

any ideas?

Have live logging running in the IDE and see what the error is there. Post the error here for further assistance.

Of and just checking that you enabled Oauth on the smartapp. Probably not the best day to work on our though due to the platform update

1 Like

Aaah, you ninja’ed in before I deleted the post - you’re right, I’d not enabled OAuth. Well, I had - but I’d not clicked Update at the bottom :wink: I realised quite soon after, but thanks for the reply anyway.

I’ve restored my post in case it helps anyone else who is trying to set this up after a 4 hour drive, 6am start and just can’t wait to get their eBay-purchased router working with SmartThings! Top tip - don’t IOT whilst tired.

So, thanks to both you and Chad (as I have an N66U so used his modified code), I’ve got decent presence detection at last .My story is this - I realised that the presence keyfobs are a bit unreliable, and also expensive - four people in the house is £120 worth of keyrings. My kids are teenagers, but when they go to school they often don’t take a key as I’m usually in. Basically, something they have to remember to take was going to be unreliable and expensive.

But teenagers eh? Smartphones? I didn’t want to force them to install the ST app, they’re always complaining that they’re running out of space or the phone is slow. But I can guarantee that phone follows them wherever they go, so the idea of using a router to detect their phones seemed ideal and I found the non-Asus specific version of this tool on this site.

I started out with an eBay Netgear WRT2000 running DD-WRT. Bad move, it’s only got 4MB Flash so can’t enable /jffs
I found an Cisco E1000. Still only has 4MB, but it gave me about 320KB of /jffs. Too small!
I upgraded to a £27 Netgear WNR-2200 as it has 8MB and a USB port. Should have done my homework, it runs an Atheros processor and most of the software is a headache… doesn’t do secure wget for example. Another router for the junk cupboard!
Finally bit the bullet and spent £40 on an N66U from eBay. Loads of flash, Merlin support, much faster anyway (the kids were really complaining when I went from my AC cablemodem to an N100 router!) and this installed absolutely fine.

Good to hear. You are sorted… That story has gotta show that the buy cheap mentality I used to subscribe to doesn’t pay off… After working in Switzerland where the Swiss absolutely subscribe to the buy cheap buy twice mentality where they always choose to buy the most expensive option. Which I used to find nuts but since trying it I do now get it.

2 Likes

It’s still not a massively expensive router, posted it was half the cost of going to a store. But once you get into the realms of scripting and smart homes I guess you need to do homework instead of just buying whatever is cheap! Other people’s experience is always handy too, should have read this thread first.

noob here, what should my App ID look like? I don’t see anything listed under “Scheduled Jobs None”

@maximus96 the IDE ineffable gas changed slightly since. The app I’d is now listed underneath the developer options section. It is a guid and is light grey in colour and is in the format xxxxxx-xxx-xxxxxxxxx-xxxx-xxxxx

Thank you

Should the < > be include in the file with the access token and app id?

Also, with a Asus RT-AC5300, should I be ing Chadly’s modified code?

@Fuzzyligic - do you know if your script will work in when the ASUS used in AP (bridge) mode?

I use mine in that mode, so yes it will work fine

1 Like

So on my RT-AC5300 with merlin firmware, I used Chadly’s modified code and I can see the name files come and go based on whether or not I’m connected to my wifi. The touching and removing files seem to work fine.

However, it seems the curl part of the code is not working as I don’t see anything happening in the live logging even though I tripped checked the access id and token, etc.

Any hints on how to trouble shoot? Thanks

@maximus96 i think the thing to do is take the router out of the equation for the moment. if you take the same string and paste it into a browser address bar on your PC, do you see anything appear in the live logging? does the presence sensor update its state?

if not then you do have issues with the app id or token.

do you see anything in the browser window?

the biggest error people make is they are taking the ID and token from the smartapp oauth settings, it is not these values as these change when you install the app and you need to get from the location -> smartapps page and find your installed app

if it does work on your browser but not on the router than you have other issues, but i am pretty sure that is not your issue unless your router does not have any name resolution via DNS

I have this working successfully with my Asus router, however it only works on the 2.4Ghz radio. How would I make it work with both the 2.4Ghz and 5Ghz radios?