Skip to content

Instantly share code, notes, and snippets.

@CedricGatay
Created May 23, 2017 19:06
Show Gist options
  • Save CedricGatay/8b48e5c5275af448716883a5986bee69 to your computer and use it in GitHub Desktop.
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
#!/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&param=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