[OBSOLETE] ASUSWRT Wifi Presence

The crazy thing is this could totally be implemented directly on the Hub… but the Hub doesn’t support that kind of ARP lookup

I think that you router has different a different wireless card for the 5ghz radio. In the script you could change the 5ghz mehod to use the wl command instead like the 2.4ghz , but with the 5ghz interface.

Having an issue where after a couple of days presence changes stop and a home file remains . Running init-start again clears it right up. It appears it quits running but no idea why, any ideas or possible solutions? Thanks!

I’ve not been experiencing this myself, that would imply an issue with Cron. what router do you have?

Asus RT-N66U running Merlin

I finally got this to work. Duh. My phone was logged into the wifi extender, for the life of me I could not figure out why it wasn’t working. Then I read this thread. Duh

I have iphone , do you have a problem with them disconnecting form the wifi if they are idol for a period of time.

@faspina I dont have iphones, allthough i heard that they do disconnect when idle which my windows phones and android phones in the house do not. but looking at a number of threads this may be a bug which can be resolved by choosing the option to “Reset Network Settings”

Quick question - how did you use rule machine to set the virtual presence sensor? I don’t seem to be able to find that as an option to set. I have been using Sharptools and Tasker on a tablet to achieve this with my daughters keyfob and phone (if one of them arrives it sets the simulated presence) but would prefer to do this in RM if possible.

@bbarham

you need to set up two custom commands on the simulated presence sensor from the expert features section, one for arrived() and the other for departed(). once this is done you can add these commands to the Run Custom Commands section in the action of a rule

Got it - thanks for the information.

It’s only on Android but I think i have narrowed it down to a overloaded channel or a POS phone.

Thanks for building this, Stuart. I got it all working with my router with some tweaks, then moved my local code over from running on the router to running on a local Ubuntu server doing the device detection using ping.

I have an older Router (RT-N66U) that doesn’t use qcsapi_sockrpc to list wifi clients. This line worked instead of the antal section:

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

I also added a -f force option to use at startup in case the router gets rebooted and the local file status is wrong:

if [ "$Chris" = Home ] then if [ ! -f /jffs/scripts/CheckUser/ChrisHome ] || [ "$1" = "-f" ]

Here’s my Ubuntu ping based script to hit the presence api. It assumes you have a DHCP reservation for your phones so they always get the same IP. Sorry for lost indentation. xxx’s are for your local IP, app ID, and app secrets.

`#!/bin/sh

ChrisIP=192.168.1.xxx
OtherIP=192.168.1.xxx

Your sever URL will be different. Grab it from the smartapp simulator.

ServerURL="https://graph-na02-useast1.api.smartthings.com/api/smartapps/installations/
ServerURL2Home=”/Phone/home?access_token=“
ServerURL2Away=”/Phone/away?access_token="
ChrisApp="xxxxxxxxxxxx"
ChrisSecret="xxxxxxxxxxxx"
OtherApp="xxxxxxxxxxxx"
OtherSecret=“xxxxxxxxxxxx”

ChrisTag=/opt/presence/ChrisHome
OtherTag=/opt/presence/OtherHome

Chris=Away
Other=Away

if /usr/local/bin/ping_test $ChrisIP; then
Chris=Home
fi

if /usr/local/bin/ping_test $OtherIP; then
Other=Home
fi

if [ “$Chris” = Home ]
then
if [ ! -f $ChrisTag ] || [ “-f” = $1 ]
then
touch $ChrisTag
curl $ServerURL$ChrisApp$ServerURL2Home$ChrisSecret -k
fi
else
if [ -f $ChrisTag ] || [ “-f” = $1 ]
then
rm -f $ChrisTag
curl $ServerURL$ChrisApp$ServerURL2Away$ChrisSecret -k
fi
fi

if [ “$Other” = Home ]
then
if [ ! -f $OtherTag ] || [ “-f” = $1 ]
then
touch $OtherTag
curl $ServerURL$OtherApp$ServerURL2Home$OtherSecret -k
fi
else
if [ -f $OtherTag ] || [ “-f” = $1 ]
then
rm -f $OtherTag
curl $ServerURL$OtherApp$ServerURL2Away$OtherSecret -k
fi
fi`

1 Like

I spoke too soon. It turns out I only tested with my S6, not the iPhone in the house. iPhones go to sleep and stop responding to pings after some amount of time, but stay in the wifi table on the router, so back to the router solution it is.

Since you said you are on Ubuntu - you could use arp -a | grep -c -E 'xx:xx:xx:xx:xx:xx' (obviously using the correct MAC ID instead of xx:xx:xx:xx:xx:xx). This will return ‘0’ if the device is not present and a value larger than 0 otherwise (whether this is 1 or something larger depends on the topology of your network).

I use that on my Mac (triggered by a cron job run once a minute) and it works great - it seems as if Ubuntu supports the same command as well.

1 Like

guys in case any of you were experiencing oddities with the the correct state display with the Virtual Presence sensor, i have updated this to v1.1 which resolved the issue of the the display not updating and matches the style of the newer presence sensor device types.

Thanks Fuzzyligic . I made a python script to handle this using your device/smartapp. https://github.com/jaytarang92/STwifiPresence

@jaytarang92 so i have a question, what is it you are doing? your not looking for the wireless interface you are using the ARP table. so how reliable is this? In my experience not very… but then you are checking DHCP. problem is my DHCP is not handled by the wireless router but via a Windows DHCP server…

im just trying to get a feel for what your may give over my solution? presumably your works with iphones? and if thats the case how quickly does it update to away?

Your solution is awesome bro. I just made this cause I was bored and bash was just not being my friend with all the spaces and stuff. My router doesn’t have wl so I read and started to use arp . What I am working on is that you can pass in the MAC and then I can get the IP address and use arping for checking .

As far as the speed goes …its almost instant… I have it wrapped in as a service .

cool i will take a look at your as it might open up some other use cases for other devices