What's new

Presence-detection with N66U / AC68U for homeautomation

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

x41

New Around Here
Hi folks,

I am getting my feed wet with homeautomation. Next step is presence detection to control different things with it.
If I am at home, do X. If my wife is, do Y etc.

The typical way used by the community is by pinging the mobile devices 24/7 from the HA-ControlCenter. A Raspberry Pi for example. But I don't like this approach at all. Noisy, error prone ... just nope.

Now I search for a method to get a list of wifi connected devices that I can parse on the router. My vision looks something like this:

My mobile joins the wifi, the router know about this and updates a plain text file with "IP, MAC, Clientname".
When I leave the wifi, it removes the entry from that file.
Everything else I can do by myself.

I found a file called "ipv6_client_list". That would be exactly what I need also for ipv4 clients. (Or a combined file would be ok too.)
I tried "/proc/net/arp" as a source - but since the arp table caches entrys for a while it's not an option either.

Do you guys have an idea? If there no way yet: \o/ Feature-Request!

Merry Christmas and thanks everybody!

x41
 
If you are specifically looking for wireless clients, these commands will show the list of currently associated wireless devices:

Code:
wl -i eth1 assoclist
wl -i eth2 assoclist

This won't work on the RT-AC87U, as the 5 GHz radio uses a different API. I don't know what's the equivalent Quantenna method to retrieve a list of associated clients.

You will have to use a cron job to regularly check what clients are associated.
 
arping might also be useful.
 
i would like to check in a shell script if a given mac address is present on the network.

wl -i eth1 assoclist

does not work, i get the error

"wl: wl driver adapter not found"

i therefore will have to use arp-a.

which commands can i use to check if $MAC_ADDRESS is present in the output of arp -a?
 
i would like to check in a shell script if a given mac address is present on the network.

wl -i eth1 assoclist

does not work, i get the error

"wl: wl driver adapter not found"

i therefore will have to use arp-a.

which commands can i use to check if $MAC_ADDRESS is present in the output of arp -a?

The command depends on the router model. What router do you have?
 
What would these be for AX88U on the latest alpha?

RT-AX88U is actually eth6 and eth7. I assumed the RT-AC86U would be the same since they share the same architecture. Best way to know for sure is running the following commands:

Code:
nvram get wl0_ifname
nvram get wl1_ifname
 
RT-AX88U is actually eth6 and eth7. I assumed the RT-AC86U would be the same since they share the same architecture. Best way to know for sure is running the following commands:

Code:
nvram get wl0_ifname
nvram get wl1_ifname

Great! Will do!

Thank you as always!


Sent from my iPhone using Tapatalk
 
My own script for detection by looking into what MAC adresses are connected to the router, might need minor updates, and adaption to what ever you might use (I have Virtual Devices in my HomeSeer 3 installation):

Code:
#!/bin/sh
#
# Mac Adress to keep track of....
# Mac1 = person one, Mac2 = person two - add more if needed (and add code below)
Mac1=00:00:00:00:00:00
Mac2=00:00:00:00:00:00

# syslog info
scr_name="$(basename $0)[$$]"

LTIME=`ls -l /tmp/var/lib/misc/dnsmasq.leases`

echo "CheckIfHome3 started..." | logger -t $scr_name

# Check if already running kind of thing
if [ ! -d /tmp/CheckUser ];
then
  echo "CheckIfHome's /tmp/CheckUser is missing, will create map." | logger -t $scr_name
  mkdir /tmp/CheckUser
else
  echo "CheckIfHome's /tmp/CheckUser exists, will exit this process." | logger -t $scr_name
  exit
fi
#
while [ 1 ]
do
#
# Variables status
  User1="Borta"
  User2="Borta"
#
# collect all mac adresses - change this if other eth parts like eth6 or what ever is needed
  macadresser=`wl -i eth1 assoclist`
#
# AC87 has a Quantenna 5GHz, needs special code
  if uname -n | grep -q AC87; then
    macadresser=`wl -i eth1 assoclist`
    antal=`qcsapi_sockrpc get_count_assoc wifi0`
    while [ $antal -gt 0 ]
    do
      antal=`expr $antal - 1`
      macadresser="`qcsapi_sockrpc get_station_mac_addr wifi0 $antal`;$macadresser"
    done
  else
    macadresser=$macadresser";"`wl -i eth2 assoclist`
# AC3200 has two 5GHz band
    if uname -n | grep -q AC3200; then
      macadresser=$macadresser";"`wl -i eth3 assoclist`
    fi
  fi
#
# User 1
  case "$macadresser" in
    *$Mac1*)
      User1="Hemma"
    ;;
  esac
#
# User 2
  case "$macadresser" in
    *$Mac2*)
      User2="Hemma"
    ;;
  esac
#
# HomeSeer integration
  if [ "$User1" == "Borta" ] ;
  then
    if [ -f /tmp/CheckUser/User1 ] ;
    then
      rm -f /tmp/CheckUser/User1
      wget -qO- "192.168.1.5/JSON?request=controldevicebylabel&ref=19&label=Away" >/dev/null 2>&1
    fi
  else
    if [ ! -f /tmp/CheckUser/User1 ] ;
    then
      touch /tmp/CheckUser/User1
      wget -qO- "192.168.1.5/JSON?request=controldevicebylabel&ref=19&label=Home" >/dev/null 2>&1
    fi
  fi

  if [ "$User2" == "Borta" ] ;
  then
    if [ -f /tmp/CheckUser/User2 ] ;
    then
      rm -f /tmp/CheckUser/User2
      wget -qO- "192.168.1.5/JSON?request=controldevicebylabel&ref=20&label=Away" >/dev/null 2>&1
    fi
  else
    if [ ! -f /tmp/CheckUser/User2 ] ;
    then
      touch /tmp/CheckUser/User2
      wget -qO- "192.168.1.5/JSON?request=controldevicebylabel&ref=20&label=Home" >/dev/null 2>&1
    fi
  fi

  sleep 5

done

echo "CheckIfHome's exits, this should not happen this way..." | logger -t $scr_name

Do change where you might need to adapt to any other integration....
 
Last edited:
Do change where you might need to adapt to any other integration....

Or replace hardcoded interfaces with $(nvram get wl0_ifname) and $(nvram get wl1_ifname), except for the RT-AC87U 5 GHz band.
 
Or replace hardcoded interfaces with $(nvram get wl0_ifname) and $(nvram get wl1_ifname), except for the RT-AC87U 5 GHz band.

Does the AC3200, with three radios (1*2.4GHz and 2*5GHz) have the same style like $(nvram get wl2_ifname)? Do you know?
 
Does the AC3200, with three radios (1*2.4GHz and 2*5GHz) have the same style like $(nvram get wl2_ifname)? Do you know?

That's correct.
 
Similar threads
Thread starter Title Forum Replies Date
I Dual WAN switching detection Asuswrt-Merlin 1

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top