Announcement

Collapse
No announcement yet.

DD-WRT Occupancy Tracking

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DD-WRT Occupancy Tracking

    Here is the script I use. I removed part of the mac addresses. The only thing I haven't figured out, it how to check the current status, save it in a variable and check the variable when a Wifi comes online to see if it should send the request to change the virtual switches status. It works well, just hate slamming the homeseer pc every 15 seconds with a current status (to change the virtual switch on the Homeseer). This script is for DD-WRT, and checks for the MACS on all three wifi's. The 2.4, the 5ghz, and the virtual 2.4 network. It is saved as a .SH and run in the Startup Script on DD-WRT. Maybe this will help someone to figure out how to make a variable and check the HomeSeer unit every 60 minutes to find out the current status so it doesn't do its changing so often. PS, this was modified from a script I used on Vera, which did check the current status so it wouldn't change it every 15 secs.

    Code:
    #!/bin/sh                                                                                                                                                                       
                                                                                                                                                                                    
    # seconds between checks                                                                                                                                                        
    WATCHDOG_SLEEP_SEC=15                                                                                                                                                           
    # HomeSeer IP Address                                                                                                                                                           
    Homeseer_IP="192.168.20.4"                                                                                                                                                      
    # MAC Address 1                                                                                                                                                                 
    MAC_ADDRESS_1="5C:AD:CF:XX:XX:XX"                                                                                                                                               
    # MAC Address 2                                                                                                                                                                 
    MAC_ADDRESS_2="78:4B:87:XX:XX:XX"                                                                                                                                               
    # MAC Address 3                                                                                                                                                                 
    MAC_ADDRESS_3="FC:C2:DE:XX:XX:XX"                                                                                                                                               
                                                                                                                                                                                    
    while sleep $WATCHDOG_SLEEP_SEC                                                                                                                                                 
    do                                                                                                                                                                              
                                                                                                                                                                                    
                                                                                                                                                                                    
    if !(/usr/sbin/wl -i eth1 assoclist| grep -Fq $MAC_ADDRESS_1) && !(/usr/sbin/wl -i eth1 assoclist| grep -Fq $MAC_ADDRESS_2) && !(/usr/sbin/wl -i eth1 assoclist| grep -Fq $MAC_ADDRESS_3) && !(/usr/sbin/wl -i eth2 assoclist| grep -Fq $MAC_ADDRESS_1) && !(/usr/sbin/wl -i eth2 assoclist| grep -Fq $MAC_ADDRESS_2) && !(/usr/sbin/wl -i eth2 assoclist| grep -Fq $MAC_ADDRESS_3)
    
    then                                                                                                                                                                            
       curl -m 1 "http://$Homeseer_IP/JSON?user=lyle@xxx&pass=xxx&request=controldevicebyvalue&ref=55&value=2" >/dev/null 2>&1                                         
    #                                                                                                                                                                               
    else                                                                                                                                                                            
       curl -m 1 "http://$Homeseer_IP/JSON?user=lyle@xxxpass=xxx&request=controldevicebyvalue&ref=55&value=1" >/dev/null 2>&1                                         
                                                                                                                                                                                    
    fi                                                                                                                                                                              
                                                                                                                                                                                    
    done

    Calling it in DD-WRT Startup Script. Change to what you named it, and obviously the location.

    Code:
    #!/bin/sh
    sh /mnt/sda2/scripts/geoseer.sh &
Working...
X