(Marcelo Franco) #364

Hi @pillock, hope this finds you well. Did you notice any side effect on turning off this option other than preventing iphones from sleeping the connection? Higher battery usage or something else?


(Randy Rands) #365

So I have had this up and working for some time now, and it has been solid. I am adding a new Access Point (AP) to the network though, and that introduces some challenges. I have read all of these posts, but still am not finding what I am after. My script looks like this:

macaddress() { wl -i eth2 assoclist && wl -i eth1 assoclist; }

if (macaddress | fgrep “XX:XX:XX:XX:XX:XX” >/dev/null)

My first question is: outside of running something off-router, does anyone have presence working using your main Asus router, an AP and this method, and if so, how (exactly) are you accomplishing that? There were some references to something along the lines of “I tried Joe’s method, slightly modified, and it works for me”, but nothing I could find specific as a “this works” solution. (this could be me - 300 posts is a lot of reading… :slight_smile:

My second question would be: Is there an issue running the above script on both the Main Router (referred to now as MR) & also the AP? If I am understanding the script correctly, every execution of it (both on the MR & also the AP) does a check & either adds or deletes the status file & calls the curl script to update status. I could see this causing an issue if the MR runs & says “away” and calls curl, but then AP runs and says “home” & calls curl. This may lead to flap (again, if I am understanding the execution correctly).

The issue with the current script is that the WL command does not list the devices connected to the AP, so they all list as “Away” when they are connected to the AP, but are in fact present on the network.

It looks like the ARP command may work to list all devices visible on the network, but I need to change my lines for Command() and also the fgrep. Particularly, I need to have fgrep look for the MAC address. I am not sure what format to use to pull out the mac being on that line. One thing to note is that the ARP table seems to be slower to update than the original method using WL, so I am not sure if it is going to be as quick, but wanted to explore the option.
My question here is mainly : Are there any linux scripting gurus that can help me re-format the above lines to incorporate the ARP command instead of WL, and also the fgrep line to filter out based on whether the MAC is there, please?

Thank you so much for your help - I appreciate it, and look forward to hearing what works for you all!

(Randy Rands) #366

So I found the answer to my 3rd question (how to use ARP) - it’s just as fast for detecting when I come ON the network, but slower to detect leaving the network. (takes up to 2 minutes, depending on where I hit the ARP refresh TTL, is what I am thinking, and that is configurable, but not sure I want the “extras” that come with changing that (i.e. more broadcast traffic)) But, coming home & things happening then is the most important to me, so I think I can live with the leaving delay. Here is what I ended up using (note that you have to convert the MAC addresses to all lower case for the fgrep as ARP puts them out in lower and fgrep is case sensitive)

Me=Away macaddress() { arp; }

if (macaddress | fgrep “38:xx:xx:b5:x2:d3” >/dev/null)
if [ “$Me” = Home ]
if [ ! -f /tmp/CheckUser/_MeHome ]
touch /tmp/CheckUser/_MeHome
curl “https://graph-na04-useast2.api.smartthings.com/api/smartapps/installations/ACCESSKEY/Phone/home?access_token=ACCESSTOKEN” -k
if [ -f /tmp/CheckUser/_MeHome ]
rm -f /tmp/CheckUser/_MeHome
curl "https://graph-na04-useast2.api.smartthings.com/api/smartapps/installations/ACCESSKEY/Phone/away?access_token=ACCESSTOKEN -k

Anyway - I hope that helps someone else - so far, it seems to be doing well.

Still interested to see if there is a better way! :slight_smile:

(pillock) #367

I added an access point and did exactly the same - swapped wl for arp and had exactly the same experience; it detects just as fast, but waits another minute or so before things fall off the network. Not a problem, but matches your experience :slight_smile:

(Klingon888) #368

Look at the second post by “wompah” - link. I’ve been using this code and its been great. The monitordevices.cfg file stores all your MAC IDs to be tracked together with its statuses. Just replace the mosquitto_pub with your curl.