A simple control unit that allows to switch Gardena 9V Valves
This project builds a controler (which serves as a substitute for e.g. the Gardena C14e) to interface up to two 9V-valves. It can be connected to a Raspberry Pi and integrated with OpenHAB or other home automation solutions via a REST based interface.
For python2
sudo apt-get install python-dev python-rpi.gpio
python -m pip install -r requirements.txt
For python3
sudo apt-get install python3-dev python3-rpi.gpio
python3 -m pip install -r requirements.txt
For autostart add the following line to /etc/rc.local
:
/bin/sleep 15 && screen -dmS Gardena bash -c "python3 /home/pi/GardenaValveCtrl/gardena_rest.py" &
In /etc/openhab2/items/default.items
the watering service can be accessed by, e.g. adding the following line (which has to be adapted your specific configuration):
Switch Gardena "Gardena Bewässerung" (gOutside) [ "Switchable" ] { http=">[ON:GET:http://gardena.local/open] >[OFF:GET:http://kitchen.local:4999/close]" }
String Gardena_Status "Gardena Status [%s]" <flow> (gOutside) { http="<[http://gardena.local/status:10000:JSONPATH($[0].status)]" }
With the upgrade to OpenHab3, the http1-Binding is deprecated. The HTTP Bindung V2 is used instead. The following has to be added to a things file:
Thing http:url:gardena "Gardena" [ baseURL="http://192.168.0.4:4999/", commandMethod="GET", refresh="2" ] {
Channels:
Type switch : switch [ commandExtension="%2$s", onValue="open", offValue="close" ]
Type string : status [ stateExtension="status", stateTransformation="JSONPATH:$[0].status" ]
}
The following has to be added to an items file:
Switch Gardena "Gardena Bewässerung" <faucet> (gOutside) [ "Switchable" ] { channel="http:url:gardena:switch" }
String Gardena_Status "Gardena Status [%s]" <flow> (gOutside) { channel="http:url:gardena:status" }
By using OpenHab together with the Hue Binding, also Amazon Alexa can be used to control the watering service.
The status page either shows closed and allows to switch on
Valve 1 is currently closed (turn on)
or shows opened and allows to switch off
Valve 1 is currently opened (turn off)
You can find further information on the project @Fritzing.