Reliable Presence Detection

I have been trying to find a reliable way for HG to know when I or a few friends are present in my home.
I have been trying this with PingMeAtHomeExtended which pings your smartphone. However I have found this to not be reliable for these reasons.

  1. The program identifies you with your local network IP as an example. This works fine until DHCP assigns a different IP.
  2. Most if not all smartphones will shutoff the wifi while idle to save battery. There are ways to keep it on but even with these adjustments it still seems to drop out.
  3. It requires a lot of constant network activity to detect you.

Has anybody found a good way to do this?

What router do you use? I use DD-WRT and run a shell script and look at the mac address table for the relevant entries like this (you would need to define the mac addresses)

# This loop will check if a device is registered on the AP and set the virtual
# switch to on or off.

# wl command is used on broadcom chipsets
# wl_atheros command is used on qualcom atheros chipsets

        # echo Starting loop
        if [ "$x" == 360 ]; then
                # Every 30 minutes or so we do them all again, just in case we missed something

        c1_new_state=`/usr/sbin/wl_atheros assoclist | grep $MAC_ADDRESS_1`
        c2_new_state=`/usr/sbin/wl_atheros assoclist | grep $MAC_ADDRESS_2`

        # If they are different or its the first run.
        if [ "$c1_new_state" != "$c1_last_state" ] || [ "$x" == 1 ] ; then
                # There has been a change so set the last state and update
                if [ "$c1_new_state" == "assoclist $MAC_ADDRESS_1" ]; then
                        # echo Device 1 user is in
                        wget -qs "http://$IP_ADDRESS/api/Presence.WifiCheck/1/Detected"

                        # echo Device 1 user is out
                        wget -qs "http://$IP_ADDRESS/api/Presence.WifiCheck/1/NotDetected"

        # If they are different or its the first run.
        if [ "$c2_new_state" != "$c2_last_state" ] || [ "$x" == 1 ] ; then
                # There has been a change so set the last state and update
                if [ "$c2_new_state" == "assoclist $MAC_ADDRESS_2" ]; then
                        # echo Device 2 user is in
                        wget -qs "http://$IP_ADDRESS/api/Presence.WifiCheck/2/Detected"
                        # echo Device 2 user is out
                        wget -qs "http://$IP_ADDRESS/api/Presence.WifiCheck/2/NotDetected"

        # Increment Counter
        x=$(( $x + 1 ))


Yup, mac addresses are the way to go. My router is very limited. To solve this I’m thinking of installing dnsmasq (?) on the Rpi that runs homegenie and have it be the dhcp dns server. That opens a lot of opportunities compared to my router. I looked into DD-WRT but it not for my actiontec router.

Currently, I’ve been using an app on my adroid phone called automate. I’m trying to get it to arm and disarm the security program. So far the results are encouraging. I have a “flow” (that’s what they call a script) based on location and one based on connection to my wifi. So far neither seems perfect.

Having the dns in the pi could help this as well. Inside I must use an ip number, outside I use a no-ip web address. So the flows must determine the connection and send the correct command. Being able to point the outside address via the host file while inside my network simplifies this greatly.

Once I get this working I plan to make the garage door automatic and have the house randomly turn lights on and off while I’m away.