Last summer I installed a sprinkler_pi box for my sprinkler system.
I chose this over opensprinkler since this setup only required a cheap relay board. It is also faster to get up and running compared to building your own solution.
But of course, you want to integrate this with HASS
It is possible to manually open/close the valves using the following url:
curl http://sprinkler:8080/bin/manual?zone=za&state=on (or off)
z a = zone number in sprinkler pi
So IĀ“ve started with this package in HASS:
switch:
- platform: command_line
switches:
valve1:
command_on: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zb&state=on\""
command_off: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zb&state=off\""
valve2:
command_on: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zc&state=on\""
command_off: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zc&state=off\""
valve3:
command_on: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zd&state=on\""
command_off: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zd&state=off\""
valve4:
command_on: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=ze&state=on\""
command_off: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=ze&state=off\""
valve5:
command_on: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zf&state=on\""
command_off: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zf&state=off\""
valve6:
command_on: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zg&state=on\""
command_off: "/usr/bin/curl \"http://sprinkler:8080/bin/manual?zone=zg&state=off\""
input_slider:
sprinklerhour:
name: Sprinkler Hour
icon: mdi:timer
initial: 9
min: 0
max: 23
step: 1
sprinklerminutes:
name: Sprinkler Minutes
icon: mdi:timer
initial: 0
min: 0
max: 55
step: 5
valve1:
name: Road Duration
initial: 60
min: 0
max: 120
step: 5
valve2:
name: Play House Duration
initial: 60
min: 0
max: 120
step: 5
valve3:
name: Hedge Duration
initial: 60
min: 0
max: 120
step: 5
valve4:
name: Gate Duration
name: Gate Duration
initial: 60
min: 0
max: 120
step: 5
valve5:
name: Lawn Duration
initial: 60
min: 0
max: 120
step: 5
valve6:
name: Rock Duration
initial: 60
min: 0
max: 120
step: 5
sensor:
platform: template
sensors:
sprinklertime:
friendly_name: 'Sprinkler Time'
value_template: '{{ states.input_slider.sprinklerhour.state | int }}:{% if states.input_slider.sprinklerminutes.state|length == 1%}0{% endif %}{{ states.input_slider.sprinklerminutes.state |int }}'
automation:
- alias: 'Sprinkler Schedule'
initial_state: true
trigger:
- platform: time
minutes: '/1'
seconds: 10
condition:
- condition: template
value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.sprinklertime.state }}'
action:
#Valve1
- service: homeassistant.turn_on
data:
entity_id:
- switch.valve1
- delay: '00:{{ states.input_slider.valve1.state | int }}:00'
- service: homeassistant.turn_off
data:
entity_id:
- switch.valve1
#Valve2
- service: homeassistant.turn_on
data:
entity_id:
- switch.valve2
- delay: '00:{{ states.input_slider.valve2.state | int }}:00'
- service: homeassistant.turn_off
data:
entity_id:
- switch.valve2
- service: notify.notify
data:
message: Sprinkler done.
Which gives me
Atm I can schedule the start time and the duration for each valve.
This can of course be combined with other services in HASS such as weather forecast and if you want to start at sunset, using Alexa(?) etc.
Using sprinkler_pi you can only have one valve open at the time. So if you have valve1 open and turn on valve2 it will automatically close valve1. This is not shown in HASS though and therefore am I using turn off after each delay in the automation.
The box:
So far it seems to work well, I have two questions though:
-
If I set the duration for one valve to 0 I would like it to completely skip that valve instead turning it on/off. Is that possible with some condition? It should of course continue to the next valve.
-
If IĀ“m not using the schedule but manually open valve1 using the switch and then (without turning it off again) turn on valve2 both valves are presented as on in HASS however only valve2 is actually open (as described above). Is it possible to fix this somehow?
Suggestions for improvements are most welcome
Thanks