19 lines
678 B
Bash
Executable File
19 lines
678 B
Bash
Executable File
#!/bin/bash
|
|
DOMO_IP="localhost" # Domoticz IP Address
|
|
DOMO_PORT="81" # Domoticz Port
|
|
OCTOPRINT_IDX=683 # numéro ID de l interrupteur du relais
|
|
|
|
json="http://akhenaton-3:5000/api/job?apikey=B5746ACFF37140D0B5F6FEAAC4413B5C"
|
|
echo "$json"
|
|
reponse=`curl -s "Accept: application/json" $json|sed -e 's/[{}]/''/g' |awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'|grep "state"|awk -F: '{print $2}'`
|
|
echo "$reponse"
|
|
|
|
if [ "$reponse" = "\"Operational\"" ]
|
|
then
|
|
echo "On eteint tout"
|
|
sleep 120
|
|
curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$OCTOPRINT_IDX&switchcmd=Off"
|
|
service motion stop
|
|
fi
|
|
|