Garden Irrigation

@SubOrbit I’m using a DIY soil moisture sensor, it works pretty good. here is the film I based it on:

i use them. they work pretty well and run for ages. only problem is distance between sensor and raspberry. it’s very limited.

What is the range? I was planing to use ESP32s as BLE-MQTT gateways using https://github.com/1technophile/OpenMQTTGateway

Good question but hard to answer. I don’t know if the rpi or the sensor is the limiting factor. Eg i have a first floor 10x10m. The rpi is on one side of the room and the miflower is 3m away from the opposite 20cm brick wall. Works fine. But if you move the sensor 5m to the side, so the total distance is 10m+ wall + square root of (3m squared and 5m squared) troubles start.

Great info, thanks! I am able to put the BLE gateway outside, about 10m from the sensor and there will be no walls between them, so I guess it should work then…

1 Like

Did you check sensors.yaml if world clock is interfering with it?

Hmmm. I thought it would be correct. Will check when I’m back home next week. Thank you.

Hi there,

There’s been either some breaking change or perhaps something is wrong with my initial code. After many months working perfectly I now have only 1 of 6 zones resetting to next run correctly.

I’ll look at the code, as soon as I’ve finished on my other projects… Perhaps a week or so.

Hello
I’m new to homeassistant, i have copied you code to my yaml files (on a fresh installation) and hass reports me this error :

RROR:homeassistant.util.yaml:mapping values are not allowed here

in “/home/homeassistant/.homeassistant/configuration.yaml”, line 70, column 12
Failed config
General Errors:
- Error loading /home/homeassistant/.homeassistant/configuration.yaml: mapping values are not allowed here
in “/home/homeassistant/.homeassistant/configuration.yaml”, line 70, column 12

Successful config (partial)

Could you help me please ?

Hi @accarien, without seeing your config - in the exact way it is in your configuration.yaml file - it’s going to be hard for anybody to help you.

Please paste the code for the element in/around line 70 and make sure you use the formatting option for ‘Preformatted text’.

Hi guys,

I’m building my greenhouse soon and starting on getting ideas for automating it. Did you see Irrigatia? I’m wondering if something exist where I could connect it to HA

Thanks

Hi all,
I’ve enjoyed reading and learning what others have done in the area of irrigation, so thought I should share my latest project which included both irrigation and controlling of a water feature pump. The project had three objectives:

  1. Water Feature pump control: Turn on in the morning and off at night. Turn off the water feature when no one is home (i.e. alarm is set).
  2. Automatically top up the Water Feature pond when the water level is low and the pump motor is no longer submerged (the water falls from the top bowl to the bottom reservoir pond, but on windy days so much water gets blown away that the reservoir water level drops quickly).
  3. Build garden and lawn irrigation system capable of being controlled from HA.
    WaterFeature

The first objective was easily managed with a Sonoff Basic Wifi switch which was purchased along with their IP66 waterproof case. I replaced the default Sonoff software with custom ESP8266 code to control and report the switch state via MQTT. The new code included a web server so that there is a simple web page to monitor and control the switch, plus it provides the Over The Air (OTA) software update functionality. A few simple HA automations now turn the water feature pump off whenever the Alarm is set and back on when someone returns home and disables the alarm. Another script switches the pump on at 7am each morning (if the alarm is not set, i.e. we are away for an extended period) and off an hour after sunset. Note that I wrote my own HA Alarm system for our home so integration with setting and clearing of the alarm is very easy.

Achieving the second objective took a bit longer! First the pond water level needed to be monitored and because a lot of water tends to get splashed around in the pond I didn’t think an ultrasonic sensor would be a good long-term solution. Nor any sort of float arrangement so I decided to 3D print a bracket that would hold a few copper probes and simply measure the conductivity between them.
PondLevelProbe
Next task was to control water flow for topping up the pond. Thanks to Petr Faitl of Tauranga, New Zealand, for the recommendation of Hunter PGV valves from Irrigation Express (we live in Lower Hutt, New Zealand). I ordered 4 of the valves so that I could add garden and lawn irrigation at the same time.


So now to put it all together and the requirements were shaping up as follows:
• Controller: I’d been experimenting with ESP8266 (in the Sonoff switches and NodeMCU guise) and had ordered some bare ESP-12 modules for just such a project so these seemed ideal.
• Software: While I could use the very good Tasmota code or ESPurna code, it’s so easy to write for the ESP8266 and there are plenty of examples of how to include MQTT, Web server, etc. so I decided to cut my own code, extending what I’d done for the Sonoff switch.
• Water Valve Control: 4 relays are required to switch 24VAC to the 4 water valves. Did briefly consider some form of solid state switching but settled on 5V relays (similar to what is used in Sonoff switches).
• Power Supply: A 24VAC supply is required to drive the valves so to avoid using another power supply it would be best to derive the 5V and 3.3V supplies from the 24VAC.
• Real world interface to water level probes, i.e. filtering and input protection.

Rather than patching this all together with bits of Veroboard and various shields I decided to layout a custom circuit board - especially as I’d come across EasyEDA (https://easyeda.com). If you have not used this site before I think it is very good! Circuit diagram and board layout all within your browser – no download of software onto your PC is required. The software works well and when the layout is complete you can click “get a quote”. Minimum order quantity is 5 boards and my double-sided boards with solder resist and component screen came in as US$2 each! US$10 for my circuit boards, made in a few days then couriered to NZ for a further SU$19 (yes courier costs were more than the board costs). And the boards are fantastic quality. Can highly recommend this service.

Anyway, back to the project. The final circuit includes a rectifier and switch mode regulator to generate the 5VDC and 3.3VDC supplies from the 24VAC, mounting of the ESP12 module, input filtering and protection for level probes, relays and drivers for valve control. And the obligatory programming push button that all ESP8266 boards require. Also threw in a 4 pin header to provide power and serial interface to the ESP8266 although after the initial boot all software updates are done via OTA.
IrrigationControllerBoard
As with all projects the mechanical aspects need a lot of attention. For this I found a waterproof case designed to hold a mains power distribution board and with enough space inside to take both my irrigation controller and the Sonoff Wifi switch. (Note that I deliberately choose not to integrate the function of the Sonoff mains switch into the irrigation controller so as to keep all 230V mains separated from the irrigation controller). A quickly designed and 3D printed bracket mounts the irrigation controller board in the case. Provision for cable clamps was included on this bracket but I never did get around to designing\printing the clamps.


And of course, digging up the lawn and running the water and electrical cables, etc. all take a lot of time. Not to mention flak from the wife for digging up the garden around the water feature. But then you can’t make a pond filler system without breaking a few hedge plants.

Putting it together: The irrigation controller is responsible for monitoring the water level and switching on the pond filler valve when the water level drops. The controller reports the water level and the state of the 4 relays into HA via MQTT. All relays can be controlled from HA or directly via a web page provided by the ESP8266 code. This web page includes the link for performing OTA software updates plus some monitoring\diagnosis. If the pond level falls to zero, then HA sends me a Slack notification that the pond is out of water - although that should be a thing of the past now that the pond is automatically replenished.
HAIrrigationTab


That just leaves me with Objective 3. There are three spare water valves available for garden\lawn irrigation but so far only one is hooked up to a sprinkler. I need to run the additional irrigation lines and then write the HA irrigation controls – which is what brought me to this post initially – looking to see what garden irrigation controls are available. During the summer in our city garden watering is limited by house numbering; even numbered houses can use irrigation on even days of the month, odd house numbers on odd days of the month. That is not seem to be a common rule in most irrigation controls and generally will require some custom coding. But its autumn now in NZ so irrigation is not so critical as it occurs naturally every few days. That gives me until next Spring to finish the irrigation part of the project. For now, I love looking at the water feature without the angst of seeing that it’s about to run out of water.
Regards
Garry

6 Likes

Hi Gary,

Nice write-up! I am currently trying to code my reticulation system into HA with the plan to use a NodeMCU (ESP8266 based) board to control the valves via relays. I wanted the interface to somewhat replicate the settings you get in most commercial retic controllers.

If it helps at all I have posted what I have coded so far, but I only started yesterday so the main smarts of it isnt there yet. At this stage I’m only coding for 2 stations but the way I am doing it allows for easy expansion as far as you need.

i have created it as a package:
reticulation.yaml

########################################
#
#   This is a full reticulation
#   control package using DarkSky
#   weather prediction to 
#   prevent watering if rain 
#   is expected, or occured recently
#   with local moisture sensor data
#   as well
#
########################################

#   Weather prediction setup
sensor:
  - platform: darksky
    api_key: !secret darksky_api_key
    name: Reticulation Weather
    forecast:
      - 1
    update_interval: '00:30:00'
    monitored_conditions:
      - precip_intensity
      - precip_probability
      - precip_intensity_max
#      - summary
#      - icon
#      - temperature
#      - apparent_temperature
#      - wind_speed
#      - wind_bearing
#      - cloud_cover
#      - humidity
#      - hourly_summary
#      - daily_summary
#      - temperature_max
#      - temperature_min
#      - apparent_temperature_max


#   Calculations for rain to stop reticulation








#   Reticulation control panel setup

input_select:
  retic_watering_days:
    name: Retic Watering Days
    options:
      - 'Daily'
      - 'Alternate'
      - '1 Wed / Sat'     # Western Australian allowed watering days based on last digit of house number
      - '2 Sun / Thurs'
      - '3 Mon / Fri'
      - '4 Tue / Sat'
      - '5 Sun / Wed'
      - '6 Mon / Thurs'
      - '7 Tue / Fri'
      - '8 Wed / Sat'
      - '9 Sun / Thurs'
      - '0 Mon / Fri'
    icon: mdi:calendar
    
input_datetime:
  retic_program1_start_time:
name: Program 1 Start Time
has_date: false
has_time: true
initial: '04:00'

  retic_program2_start_time:
name: Program 2 Start Time
has_date: false
has_time: true
initial: '18:00'


input_number:
  retic_program1_station1_run_time:
name: Station 1 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer

  retic_program1_station2_run_time:
name: Station 2 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer

  retic_program2_station1_run_time:
name: Station 1 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer

  retic_program2_station2_run_time:
name: Station 2 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer  

input_boolean:
  retic_watering_day:

  retic_station1_manual_run:
name: ON Manual
icon: mdi:arrow-right-drop-circle

  retic_station2_manual_run:
name: ON Manual
icon: mdi:arrow-right-drop-circle

  retic_station1_auto_run:

  retic_station2_auto_run:

  retic_program1_enable:
name: Enable

#  retic_program1_station1:
#    name: Station 1
#    icon: mdi:play-protected-content

#  retic_program1_station2:
#    name: Station 2
#    icon: mdi:play-protected-content

  retic_program2_enable:
name: Enable

#  retic_program2_station1:
#    name: Station 1
#    icon: mdi:play-protected-content

#  retic_program2_station2:
#    name: Station 2
#    icon: mdi:play-protected-content


group:                  # frontend interface setup
  retic_manual:
control: hidden
name: 'Manual Control'
entities:
  - input_boolean.retic_station1_manual_run
  - input_boolean.retic_station2_manual_run
  
  retic_program1:
    control: hidden
    name: 'Program 1'
    entities:
      - input_boolean.retic_program1_enable
      - input_select.retic_watering_days
      - input_datetime.retic_program1_start_time
      - input_number.retic_program1_station1_run_time
      - input_number.retic_program1_station2_run_time
    
  retic_program2:
    control: hidden
    name: 'Program 2'
    entities:
      - input_boolean.retic_program2_enable
      - input_select.retic_watering_days
      - input_datetime.retic_program2_start_time
      - input_number.retic_program2_station1_run_time
      - input_number.retic_program2_station2_run_time
  
switch:                      # Solenoid control (will be signals to NodeMCU)
  - platform: mqtt
name: "Retic Station 1 Valve"
state_topic: "retic/station1/state"
command_topic: "retic/station1/cmd"
payload_on: "1"
payload_off: "0"
optimistic: false
qos: 0
retain: true

  - platform: mqtt
name: "Retic Station 2 Valve"
state_topic: "retic/station2/state"
command_topic: "retic/station2/cmd"
payload_on: "1"
payload_off: "0"
optimistic: false
qos: 0
retain: true


#automation:
#  - alias: Check watering day
#    initial_state: 'on'
#    trigger:
#      - platform: time
#        at: '00:00:00'
#    condition:
#      condition: or
#      conditions:
#        - condition: state
#          entity_id: input_select.retic_watering_days
#          state: 'Daily'


#  - alias: Reticulation Run Program 1
#    initial_state: 'on'
#    trigger:
#      - platform: template
#        value_template: '{{ states.sensor.time.state == (states.input_datetime.retic_program1_start_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}'
#    condition:
#      condition: and
#      conditions:
#        - condition: state
#          entity_id: input_boolean.retic_program1_enable
#          state: 'on'
#        - condition: state
#          entity_id: input_boolean.retic_watering_day
#          state: 'on'
#    action:

As you can see its not complete but it will give you the interface to see how it will come together. I will try to work on getting all the automation side of it coded over the next week.

Thanks Dave,
That’s a great start to irrigation controls! I’ve dropped your code into my dev system and it looks good. Exactly what I was looking for.

Let me know when you get it finished or further along the way.

Cheers
Garry

no problem, hopefully you got the latest version because I made a couple of edits and updated my post. I will certainly post the full version here once I finish it. At the end of the day, I wouldn’t have gotten to where I am with coding this stuff without this forum so it’s nice to give something back!

Not sure why but for some reason if I run a config check on the below code, it spits out the below error. It passes the config check if I # out the automation “Reticulation Run Program 1” but I can’t see how that relates to the error I’m getting… any ideas?
image

reticulation.yaml

########################################
#
#   This is a full reticulation
#   control package using DarkSky
#   weather prediction to 
#   prevent watering if rain 
#   is expected, or occured recently
#   with local moisture sensor data
#   as well
#
########################################

#   Weather prediction setup
sensor:
  - platform: darksky
    api_key: !secret darksky_api_key
    name: Reticulation Weather
    forecast:
      - 1
    update_interval: '00:30:00'
    monitored_conditions:
      - precip_intensity
      - precip_probability
      - precip_intensity_max
#      - summary
#      - icon
#      - temperature
#      - apparent_temperature
#      - wind_speed
#      - wind_bearing
#      - cloud_cover
#      - humidity
#      - hourly_summary
#      - daily_summary
#      - temperature_max
#      - temperature_min
#      - apparent_temperature_max


#   Calculations for rain to stop reticulation

















#   Reticulation control panel setup

input_select:
  retic_watering_days:
    name: Retic Watering Days
    options:
      - 'Daily'
      - 'Alternate'
      - '1 Wed / Sat'     # Western Australian allowed watering days based on last digit of house number
      - '2 Sun / Thurs'
      - '3 Mon / Fri'
      - '4 Tue / Sat'
      - '5 Sun / Wed'
      - '6 Mon / Thurs'
      - '7 Tue / Fri'
      - '8 Wed / Sat'
      - '9 Sun / Thurs'
      - '0 Mon / Fri'
    icon: mdi:calendar
    
input_datetime:
  retic_program1_start_time:
    name: Program 1 Start Time
    has_date: false
    has_time: true
    initial: '04:00'

  retic_program2_start_time:
    name: Program 2 Start Time
    has_date: false
    has_time: true
    initial: '18:00'


input_number:
  retic_program1_station1_run_time:
    name: Station 1 Run Time
    initial: 10
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer

  retic_program1_station2_run_time:
    name: Station 2 Run Time
    initial: 10
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer

  retic_program2_station1_run_time:
    name: Station 1 Run Time
    initial: 10
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer

  retic_program2_station2_run_time:
    name: Station 2 Run Time
    initial: 10
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer  

input_boolean:
  retic_watering_day:

  retic_station1_manual_run:
    name: Station 1 ON Manual
    icon: mdi:arrow-right-drop-circle

  retic_station2_manual_run:
    name: Station 2 ON Manual
    icon: mdi:arrow-right-drop-circle

  retic_station1_auto_run:

  retic_station2_auto_run:

  retic_program1_enable:
    name: Enable
    
#  retic_program1_station1:
#    name: Station 1
#    icon: mdi:play-protected-content

#  retic_program1_station2:
#    name: Station 2
#    icon: mdi:play-protected-content

  retic_program2_enable:
    name: Enable

#  retic_program2_station1:
#    name: Station 1
#    icon: mdi:play-protected-content

#  retic_program2_station2:
#    name: Station 2
#    icon: mdi:play-protected-content


group:                  # frontend interface setup
  retic_manual:
    control: hidden
    name: 'Manual Control'
    entities:
      - input_boolean.retic_station1_manual_run
      - input_boolean.retic_station2_manual_run
  
  retic_program1:
    control: hidden
    name: 'Program 1'
    entities:
      - input_boolean.retic_program1_enable
      - script.retic_program1_run
      - input_select.retic_watering_days
      - input_datetime.retic_program1_start_time
      - input_number.retic_program1_station1_run_time
      - input_number.retic_program1_station2_run_time
    
  retic_program2:
    control: hidden
    name: 'Program 2'
    entities:
      - input_boolean.retic_program2_enable
      - script.retic_program2_run
      - input_select.retic_watering_days
      - input_datetime.retic_program2_start_time
      - input_number.retic_program2_station1_run_time
      - input_number.retic_program2_station2_run_time
      
      
switch:                      # Solenoid control (will be signals to NodeMCU)
  - platform: mqtt
    name: "Retic Station 1 Valve"
    state_topic: "retic/station1/state"
    command_topic: "retic/station1/cmd"
    payload_on: "1"
    payload_off: "0"
    optimistic: false
    qos: 0
    retain: true
    
  - platform: mqtt
    name: "Retic Station 2 Valve"
    state_topic: "retic/station2/state"
    command_topic: "retic/station2/cmd"
    payload_on: "1"
    payload_off: "0"
    optimistic: false
    qos: 0
    retain: true


#automation:
#  - alias: Check watering day
#    initial_state: 'on'
#    trigger:
#      - platform: time
#        at: '00:00:00'
#    condition:
#      condition: or
#      conditions:
#        - condition: state
#          entity_id: input_select.retic_watering_days
#          state: 'Daily'


#  - alias: Reticulation Run Program 1
#    initial_state: 'on'
#    trigger:
#      - platform: template
#        value_template: '{{ states.sensor.time.state == (states.input_datetime.retic_program1_start_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}'
#    condition:
#      condition: and
#      conditions:
#        - condition: state
#          entity_id: input_boolean.retic_program1_enable
#          state: 'on'
#        - condition: state
#          entity_id: input_boolean.retic_watering_day
#          state: 'on'
#    action:
#      - service: script.turn_on
#        entity_id: script.retic_program1_run


script:             #run retic program 1 through each station for selected time
  retic_program1_run:
    alias: Program 1 Run
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_1_valve
      - delay: "00:{{ states('input_number.retic_program1_station1_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_1_valve
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_2_valve
      - delay: "00:{{ states('input_number.retic_program1_station2_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_1_valve
      
  retic_program2_run:
    alias: Program 2 Run
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_1_valve
      - delay: "00:{{ states('input_number.retic_program2_station1_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_1_valve
      - service: switch.turn_on
        data:
          entity_id: switch.retic_station_2_valve
      - delay: "00:{{ states('input_number.retic_program2_station2_run_time')|int }}:00"
      - service: switch.turn_off
        data:
          entity_id: switch.retic_station_1_valve

groups.yaml #for completeness I have included a segment of this file

retic:
  name: Retic
  view: yes
  icon: mdi:barley
  entities:
    - group.retic_program1
    - group.retic_program2
    - group.retic_manual

So the interface looks like this so far:

But if someone can help with the error I’m getting I’ll be very appreciative!

1 Like

Hi, these projects seem awesome for home automation!

Just chiming in here because I think a project of mine, esphomeyaml could, I hope, make setup easier. It’s basically software that creates custom firmwares for ESP8266/ESP32 boards from YAML configuration files as Home Assistant. :see_no_evil:

1 Like

I already had your thread about that bookmarked for when I put together the hardware side of my project!

1 Like

@sparkydave You don’t seem to have an action for the automation ‘Check watering day’.

Yeah, that part is incomplete hence its #'d out. It’s just the other automation that causes the error.
Edit:sorry, I forgot that both automations were #'d out! But it’s only the second one that causes trouble, the first is simply incomplete because it’s a work in progress