Created
May 23, 2017 19:06
-
-
Save CedricGatay/8b48e5c5275af448716883a5986bee69 to your computer and use it in GitHub Desktop.
Presence detection using https://github.com/CedricGatay/asuswrt-presence for asus wrt network presence scanning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
AUTH=AUTHTOKEN; | |
ASUSWRTPRESENCEIP=IP; | |
DOMOTICZ_IP=IP; | |
DOMOTICZ_PORT=PORT; | |
curl --silent http://$ASUSWRTPRESENCEIP:9090 > devices | |
function checkPresence { | |
D=$(cat devices | jq ".\"$1\".status" | tr -d '"'); | |
if [[ "y$D" == 'yFAILED' || "y$D" == 'y' ]]; then CMD="Off"; else CMD="On"; fi | |
INDEX=$2 | |
URL="http://$DOMOTICZ_IP:$DOMOTICZ_PORT/json.htm?type=command¶m=switchlight&idx=$INDEX&switchcmd="; | |
curl --silent -H "Authorization: Basic $AUTH" $URL$CMD | |
} | |
checkPresence 192.168.0.203 252 | |
checkPresence 192.168.0.201 253 | |
rm devices |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment