-
Notifications
You must be signed in to change notification settings - Fork 100
External Zone Control Script
In versions after 1.5.0 you may use an external script to control zones. Note: this feature is not available on Arduino.
Create an executable file at /usr/local/bin/sprinklers_pi_zone
and set your output type to "None" to enable this feature.
The path to the script may be changed in config.h
.
The script will be called for every zone with its state whenever there is a change to any zone. It will be called with the following signature:
/usr/local/bin/sprinklers_pi_zone [zone_number] [state]
zone_number: integer corresponding to the zone number configured in settings
state: 0 for "off", 1 for "on"
You can do whatever you want with this information, if you want to have some locally controlled pins and some external pins you can manually pass through to the command line version of wiring pi for the local pins.
You may find example zone control scripts in the scripts directory of this project as they are written and contributed back.
This simple example script just logs when zones are changed and passes through to wiring pi's command line gpio
tool:
#!/bin/bash
echo "PIN: $1 OUTPUT: $2" >> /tmp/zone.log
gpio write $1 $2
At startup all the zones are set to off which would produce the following output:
PIN: 0 OUTPUT: 0
PIN: 1 OUTPUT: 0
PIN: 2 OUTPUT: 0
PIN: 3 OUTPUT: 0
PIN: 4 OUTPUT: 0
PIN: 5 OUTPUT: 0
PIN: 6 OUTPUT: 0
PIN: 7 OUTPUT: 0
PIN: 8 OUTPUT: 0
PIN: 9 OUTPUT: 0
PIN: 10 OUTPUT: 0
PIN: 11 OUTPUT: 0
PIN: 12 OUTPUT: 0
PIN: 13 OUTPUT: 0
PIN: 14 OUTPUT: 0
PIN: 15 OUTPUT: 0
Then if you turn on Zone 2 it would output this:
PIN: 0 OUTPUT: 0
PIN: 1 OUTPUT: 0
PIN: 2 OUTPUT: 1
PIN: 3 OUTPUT: 0
PIN: 4 OUTPUT: 0
PIN: 5 OUTPUT: 0
PIN: 6 OUTPUT: 0
PIN: 7 OUTPUT: 0
PIN: 8 OUTPUT: 0
PIN: 9 OUTPUT: 0
PIN: 10 OUTPUT: 0
PIN: 11 OUTPUT: 0
PIN: 12 OUTPUT: 0
PIN: 13 OUTPUT: 0
PIN: 14 OUTPUT: 0
PIN: 15 OUTPUT: 0