UPDATE: I have modified the script (below) to support a
pause-all command. To add this command execute the following commands from a terminal window
- Code: Select all
cd /Library/Application\ Support/Perceptive\ Automation/Scripts # Change directory to the Indigo Scripts folder
ln zone-on pause-all # create a link (alias) to the zone-on script for the abort-all function
Then in an Action Group set the Run Shell Script command to
- Code: Select all
/Library/Application\ Support/Perceptive\ Automation/Scripts/pause-all xx
where
xx is the duration in minutes to pause. To end a pause early, set the value to 0. So, you could have 2 actions: one to pause, another to stop the pause.
Now, about the
RegenMaschine API. It is probably the way to go for the future. However, since it adds no real functionality, I am not going to switch to it right now since the existing shell script does everything we can do anyway.
Here is the updated script. Make sure you change the IP Address (ADDR) and Password (PWD) at the top of the script.
- Code: Select all
#!/bin/ksh
ADDR=aaa.bbb.ccc.ddd
PWD=xxxxx
# No user changes below this line
DEBUG=false
if $DEBUG; then set -x; fi
CMD=`basename "$0"`
DUR=000
TOKEN=`curl --include \
--insecure \
-s \
--request POST \
--header "Content-Type: application/json" \
--data-binary "{ \"pwd\": \"${PWD}\", \"remember\": 1 }" } https://${ADDR}:8080/api/4/auth/login`
TOKEN2=`echo $TOKEN|cut -d\" -f4`
case "$CMD" in
last-vals)
if $DEBUG; then echo received log-days; fi
SDATE=""
SDAYS=""
if [[ $1 -ne "" ]]; then SDATE=/$1; fi
if [[ $2 -ne "" ]]; then SDAYS=/$2; fi
#curl --include \
curl --insecure \
https://${ADDR}:8080/api/4/watering/past${SDATE}${SDAYS}?access_token=$TOKEN2 > \
"/Library/Application Support/Perceptive Automation/Scripts/water_data.json"
;;
log-days)
if $DEBUG; then echo received log-days; fi
SDATE=$1 # end date YYYY-MM-DD
SDAYS=$2 # days previous
curl --include \
--insecure \
https://${ADDR}:8080/api/4/watering/log/details/${1}/${2}?access_token=$TOKEN2
;;
zone-props)
if $DEBUG; then echo received log-days; fi
ZONE=$1
curl --include \
--insecure \
https://${ADDR}:8080/api/4/zone/${ZONE}?access_token=$TOKEN2
;;
abort-all)
if $DEBUG; then echo received abort-all; fi
curl --include \
--insecure \
--request POST \
--data-binary "{ \"access_token\": ${TOKEN2} }" \
https://${ADDR}:8080/api/4/watering/stopall?access_token=$TOKEN2
;;
cycle-start)
# $1 = cycle
if $DEBUG; then echo received cycle-start; fi
PRG=$1
curl --include \
--insecure \
--request POST \
--data-binary "{ \"time\": ${DUR} }" \ # This should be unecessary, but it seems to be required
https://${ADDR}:8080/api/4/program/${PRG}/start?access_token=$TOKEN2
echo -n "program ${PRG}:"
;;
global-disable)
if $DEBUG; then echo received global-disable; fi
# Not yet implemented. Not sure if this is even supported in the API
;;
global-enable)
if $DEBUG; then echo received global-enable; fi
# Not yet implemented. Not sure if this is even supported in the API
;;
pause-all)
# $1 duration
if $DEBUG; then echo received pause-all; fi
let DUR=$1*60
curl --include \
--insecure \
--request POST \
--data-binary "{ \"duration\": ${DUR} }" \
https://${ADDR}:8080/api/4/watering/pauseall?access_token=$TOKEN2
echo -n "zone ${ZN}:"
;;
pct-mod)
# $1 = global percentage
# Not yet implemented.
if $DEBUG; then echo received pct-mod; fi
;;
status)
if $DEBUG; then echo received queue; fi
curl --include \
--insecure \
--request GET \
https://${ADDR}:8080/api/4/watering/zone?access_token=$TOKEN2
;;
restart)
if $DEBUG; then echo received restart; fi
curl --include \
--insecure \
--request POST \
--data-binary "{ \"time\": ${DUR} }" \
https://${ADDR}:8080/api/4/machine/reboot?access_token=$TOKEN2
;;
zone-on)
# $1 = zone, $2 = duration
if $DEBUG; then echo received zone-on; fi
ZN=$1
let DUR=$2*60
curl --include \
--insecure \
--request POST \
--data-binary "{ \"time\": ${DUR} }" \
https://${ADDR}:8080/api/4/zone/${ZN}/start?access_token=$TOKEN2
echo -n "zone ${ZN}:"
;;
*) echo invalid operation selected: $CMD
;;
esac
exit 0