Yet another presence detection method DOMOTICZ ASUS

                                                                             presence_detection                                                                                  

!/bin/sh

mac=$1
idx=$2
device_present=Off
domoticz_status=curl -s "http://xxxx:xxxx@xxxx.xxx.0.xxx:xxxx/json.htm?type=devices&rid=$idx" | grep Status | awk '{print $3}' | sed 's/[",]//g'
for x in wl -i eth1 assoclist | awk '{print $2}'; do
if [ $x = $mac ]; then
device_present=On
fi
done

look in 5GHz (eth2) network for device

for x in wl -i eth2 assoclist | awk '{print $2}'; do
if [ $x = $mac ]; then
device_present=On
fi
done
echo "Domoticz: $domoticz_status, router: $device_present"

tell domoticz the new device status

if [ $domoticz_status != $device_present ]; then

if [ $device_present = "On" ]; then curl -s "http://xxxx:xxx@xxx.xxx.0.xxx:xxxx/json.htm?type=command&param=switchlight&idx=$idx&switchcmd=On" > /dev/null

else curl -s "http://xxx:xxx@xxx.xxx.0.xxx:xxxx/json.htm?type=command&param=switchlight&idx=$idx&switchcmd=Off" > /dev/null

fi

fi

Yet another presence detection method - Domoticz