Garden Irrigation

Great setup, thanks for sharing!
Where and why are you using the rectifier diodes? :slight_smile:

Edit: Sorry, found your explanation now. I have 12vDC valves and power supply, so I guess I dont need them.

correct. only needed for AC power supply.

Hi all

I have no data informations for weather.
My gruoup looks like this after few days

Where should I check to find the solution?

Thanks

I haven’t had a chance to test yet since I’ve been away too, but I’ll give your newly debugged a code a try tonight or tomorrow! I also did run across this while I was gone. Do you use the recorder component and its restore_state function? Without testing it reads exactly like the solution needed. [link to docs]

I haven’t tried it with anything else yet, but I will if I keep running into issues – I’m also using MQTT for control so the state is definitely fed back to HA, since the listing of the valves as switches work fine. I’ll see where we’re at tomorrow. Thanks so much!!

yep, I am relying on the recorder: component to restore the states on restart

1 Like

hi @pyrosmiley, I just did some testing and found more issues. This code below works for me after flashing a NodeMCU with ESPhomeyaml.

reticulation.yaml (package) (stilll doesnt have the weather stuff added…one day)

########################################
#
#   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
#
#
########################################


sensor:
  - platform: darksky      #   Weather setup
    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_high


      

  - platform: template    # determine if today is selected as a watering day for program 1
    sensors:
      retic_program1_watering_day:
        value_template:  >
          {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
          {% set today_name = sensor_names[now().weekday()] %}
          {% set entity_id = 'input_boolean.retic_program1_'+today_name %}
          {{ is_state(entity_id, 'on') }}

      retic_program2_watering_day:
        value_template:  >
          {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
          {% set today_name = sensor_names[now().weekday()] %}
          {% set entity_id = 'input_boolean.retic_program2_'+today_name %}
          {{ is_state(entity_id, 'on') }}

#   Calculations for rain to stop reticulation


















    
input_datetime:
  retic_program1_start_time:    # program start time control
    name: Program 1 Start Time
    has_date: false
    has_time: true


  retic_program2_start_time:
    name: Program 2 Start Time
    has_date: false
    has_time: true



input_number:
  retic_program1_station1_run_time:   # station run time control
    name: Station 1 Run Time
    min: 0
    max: 30
    step: 1
    icon: mdi:camera-timer

  retic_program1_station2_run_time:
    name: Station 2 Run Time
    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_program1_monday:   # watering day selections for program 1
    name: Monday

  retic_program1_tuesday:
    name: Tuesday

  retic_program1_wednesday:
    name: Wednesday

  retic_program1_thursday:
    name: Thursday
    
  retic_program1_friday:
    name: Friday

  retic_program1_saturday:
    name: Saturday
    
  retic_program1_sunday:
    name: Sunday

  retic_program2_monday:   # watering day selections for program 2
    name: Monday

  retic_program2_tuesday:
    name: Tuesday

  retic_program2_wednesday:
    name: Wednesday

  retic_program2_thursday:
    name: Thursday
    
  retic_program2_friday:
    name: Friday

  retic_program2_saturday:
    name: Saturday
    
  retic_program2_sunday:
    name: Sunday


  retic_program1_enable:
    name: Enable
    
  retic_program2_enable:
    name: Enable


group:                  # frontend interface setup
  retic_manual:
    control: hidden
    name: 'Manual Control'
    entities:
      - switch.retic_station_1_valve
      - switch.retic_station_2_valve
  
  retic_program1:
    control: hidden
    name: 'Program 1'
    entities:
      - input_boolean.retic_program1_enable
      - script.retic_program1_run
      - input_datetime.retic_program1_start_time
      - group.retic_program1_watering_days
      - group.retic_program1_run_times
    
  retic_program2:
    control: hidden
    name: 'Program 2'
    entities:
      - input_boolean.retic_program2_enable
      - script.retic_program2_run
      - input_datetime.retic_program2_start_time
      - group.retic_program2_watering_days
      - group.retic_program2_run_times

  retic_program1_watering_days:
    control: hidden
    name: 'Watering days'
    icon: mdi:calendar-multiple-check
    entities:
      - input_boolean.retic_program1_monday
      - input_boolean.retic_program1_tuesday
      - input_boolean.retic_program1_wednesday
      - input_boolean.retic_program1_thursday
      - input_boolean.retic_program1_friday
      - input_boolean.retic_program1_saturday
      - input_boolean.retic_program1_sunday

  retic_program2_watering_days:
    control: hidden
    name: 'Watering days'
    icon: mdi:calendar-multiple-check
    entities:
      - input_boolean.retic_program2_monday
      - input_boolean.retic_program2_tuesday
      - input_boolean.retic_program2_wednesday
      - input_boolean.retic_program2_thursday
      - input_boolean.retic_program2_friday
      - input_boolean.retic_program2_saturday
      - input_boolean.retic_program2_sunday

  retic_program1_run_times:
    control: hidden
    name: 'Run times'
    icon: mdi:camera-timer
    entities:
      - input_number.retic_program1_station1_run_time
      - input_number.retic_program1_station2_run_time

  retic_program2_run_times:
    control: hidden
    name: 'Run times'
    icon: mdi:camera-timer
    entities:
      - input_number.retic_program2_station1_run_time
      - input_number.retic_program2_station2_run_time
 
      
#switch:                      # Solenoid control (will be signals to NodeMCU) THIS SECTION IS NOT NEEDED WHEN YOU CREATE YOUR SWITCHES VIA ESPHOMNEYAML AS THEY WILL BE CREATED ELSEWHERE BUT YOU HAVE TO USE THE SAME NAMES
#  - 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: Reticulation Run Program 1     # start program 1 at designated time if it is enabled and today is selected as a watering day
    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: sensor.retic_program1_watering_day
          state: 'true'
    action:
      - service: script.turn_on
        entity_id: script.retic_program1_run

  - alias: Reticulation Run Program 2     # start program 2 at designated time if it is enabled and today is selected as a watering day
    initial_state: 'on'
    trigger:
      - platform: template
        value_template: '{{ states.sensor.time.state == (states.input_datetime.retic_program2_start_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}'
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: input_boolean.retic_program2_enable
          state: 'on'
        - condition: state
          entity_id: sensor.retic_program2_watering_day
          state: 'true'
    action:
      - service: script.turn_on
        entity_id: script.retic_program2_run


script:
  retic_program1_run:             #run retic program 1 through each station for selected time
    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_2_valve
      
  retic_program2_run:             #run retic program 2 through each station for selected time
    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_2_valve
1 Like

I’ve been looking at this today and liked how you did the rain history. With everything said regarding inaccurate data etc, I’m starting to think that perhaps I should only include the rain forecast and then use a local moisture sensor. I did buy moisture sensors for this project for this very reason so I should use them. I figure I will use the % chance of a decent amount of rain for tomorrow as a factor on watering today, as well as current soil moisture level measured just before the watering is to take place. It’s not as complex and impressive as your calculations but at I think the local moisture level is better than a ‘possible’ history value, since the history may not be localised enough. ie: it rained at my nearest weather station but not in my back yard.

@woody4165

Hi and sorry for the late reply but I have been away for two weeks (and came back to a well watered garden :slight_smile:). Did you solve this?

I don’t have

forecast:
  - 1

in my sensor config but apart from that it is the same as mine.

However, as I have said previously I got disillusioned with the data I was able to collect for rainfall so that part may well be giving strange information as I was tinkering with it a lot. I am currently not using it and to be honest I am not sure what state I left it in, Although the principle works and the code should be easily modified if you have sensible data.

The temp info should definitely show some data though.

Blush

I think the way you are going is a much better solution than mine :slight_smile:
What moisture sensors did you buy? I am considering using a way to gather the data myself, either moisture sensors or a rain gauge.

I’m interested in what you come up with…

I just bought the cheap ones like below:
image

I have since watched a youtube video about them and may look to upgrading it later. The difference I will use is to not leave the moisture sensor energised other than when taking readings. Thats the way to make these cheap ones last so you dont end up destroying them like in the vidoe.

Unfortunately I’m trying to work on too many parts of my HA setup at once because there is so much it can do / many sweet GUI upgrades that the hardware side of things has been slow.

do we even know what the perfect MOISTURE PERCENTAGE for our lawn would be?
i got some miflora sensors, and they show very stable but even more very unbelievable values. even if i water the lawn once a day with 10mm of water they show 6%. and this can’t be enough or true.

Thats going to come down to the soil type etc, and the accuracy of the sensor. They way I would go is to not worry about the number as such, but the actual feel of the ground itself and adjust accordingly. a quick google suggests about 25% for lawn. Is your probe correct or is it worth using a calculation to adjust / calibrate it?

Blimey! 50 cents + 8 cents delivery to the UK!
I’m going to get a few of these and have a play - thanks for the pointer.

  1. This is honestly exactly what I was hoping to make, interface-wise, I love it.

  2. That said, as I’m already making my brain hurt trying to set up some latching solenoids (I’ve settled on Espurna, but it’s still all MQTT switches), I noticed something kinda important: the reticulation programs aren’t being triggered automatically? They work perfectly when I trigger it manually, but they’re not starting on their own. I’ve added the datetime sensor to my config, which I thought for sure would fix my problem, but alas. Am I missing something?

I poked around at the various alarm clock projects (which is next for me, actually) and tried swapping out the YAML for triggers other people have used, to no avail.

I even tried a fresh HASS install. Is there something I’m supposed to do that I just somehow missed? Sorry to bother after all your work on this

I just tried this myself using my half built hardware solution and it isnt triggering for me either. I used the code from my alarm clock config which works… I’ll have to look into it and get back to you. Sorry about that

1 Like

I´ve started to implement my local weather station into @klogg version (I like its preciseness and modularity) :+1::+1: Nonetheless relay to the weather forecast only is a bit problematic.
So far I have done: correction if it rains.
Working on cycle postponing if wind is over limit and local precipitation implementation.

I could sum it up once it will be done.

I’m very interested to see what you come up with.

Hardware:

So far I have connected Rain sensor - to set up 0 min cycle time if it rains
As waiting for wemos delivery, currently testing windspeed sensor connected to Sonoff Basic, it works quite well. Tested up to 10 m/s (have no opportunity to test whole range of windspeed yet :slight_smile: )
2 sensors (wind speed, precipitation) connected directly to wemos with rules activated
1 sensor (wind direction) connected through INA219 to wemos.
Precipitation sensor will count continually 24 hrs, MQTTs “total”, resets automatically and starts again => theoretically unlimited precipitation historical data available

Adjustment If it rains - added to garden_weather_calculation.yaml script:

sensor.rain_1 gives 1/0 (1 = no rain/0 rain)

 # Adjust if it rains
  - service: input_number.set_value
    data_template:
      entity_id: input_number.adjusted_cycle{{ cycle }}_zone{{ zone }}_duration
      value: >
        {% set duration = states('input_number.cycle' + cycle + '_zone' + zone + '_duration') %}
        {% set adj_duration = states('input_number.adjusted_cycle' + cycle + '_zone' + zone + '_duration') %}
          {{ float(adj_duration) - (float(duration) * float(states.input_number.rain_3days_ratio.state)) * (states.sensor.rain_1.state) | int }}

Hi @pyrosmiley , I think I have worked out what is going on and I’m looking at how to fix it. The question is why, because I have the same code in my alarm clock package which works perfectly.

You do need to have sensor.time somewhere in your setup, I don’t have it in the package because it already exists elsewhere.

When I check the states in the dev page, input_datetime.retic_program1_start_time is shown as 10:44:00 (ie: includes seconds) whereas the sensor.time does not have seconds… perhaps that is an issue? but why since the alarm clock works. My understanding of the template trigger code is that it is supposed to ignore the seconds.
I also tried:

value_template: '{{ states.sensor.time.state == states.input_datetime.retic_program1_start_time }}'

but that didn’t work either. I’ll keep hunting for an explanation / solution unless someone else on here can help in the meantime

1 Like

Hi @pyrosmiley I found the error. It was a stupid lowercase t in place of a capital T… :smirk: So here is a cleaned up copy of my entire code which now works:

reticulation.yaml

    ########################################
    #
    #   This is a full reticulation
    #   control package using ESPHOMEYAML
    #   as the soleniod control via a NodeMCU
    #   Weather adaptive watering control to 
    #   be added later
    #
    ########################################

    homeassistant:
      customize:
        switch.retic_station_1_valve:
          icon: mdi:water-pump
        switch.retic_station_2_valve:
          icon: mdi:water-pump
        




          
sensor:
      - platform: template    # determine if today is selected as a watering day for program 1
        sensors:
          retic_program1_watering_day:
            value_template:  >
              {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
              {% set today_name = sensor_names[now().weekday()] %}
              {% set entity_id = 'input_boolean.retic_program1_'+today_name %}
              {{ is_state(entity_id, 'on') }}

          retic_program2_watering_day:
            value_template:  >
              {% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
              {% set today_name = sensor_names[now().weekday()] %}
              {% set entity_id = 'input_boolean.retic_program2_'+today_name %}
              {{ is_state(entity_id, 'on') }}

    #   Calculations for rain to stop reticulation

    # TO BE COMPLETED LATER....
















        
    input_datetime:
      retic_program1_start_time:    # program start time control
        name: Program 1 Start Time
        has_date: false
        has_time: true

      retic_program2_start_time:
        name: Program 2 Start Time
        has_date: false
        has_time: true


    input_number:
      retic_program1_station1_run_time:   # station run time control
        name: Station 1 Run Time
        min: 0
        max: 30
        step: 1
        icon: mdi:camera-timer

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

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

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

    input_boolean:
      retic_program1_monday:   # watering day selections for program 1
        name: Monday

      retic_program1_tuesday:
        name: Tuesday

      retic_program1_wednesday:
        name: Wednesday

      retic_program1_thursday:
        name: Thursday
        
      retic_program1_friday:
        name: Friday

      retic_program1_saturday:
        name: Saturday
        
      retic_program1_sunday:
        name: Sunday

      retic_program2_monday:   # watering day selections for program 2
        name: Monday

      retic_program2_tuesday:
        name: Tuesday

      retic_program2_wednesday:
        name: Wednesday

      retic_program2_thursday:
        name: Thursday
        
      retic_program2_friday:
        name: Friday

      retic_program2_saturday:
        name: Saturday
        
      retic_program2_sunday:
        name: Sunday


      retic_program1_enable:
        name: Enable
        
      retic_program2_enable:
        name: Enable


    group:                  # frontend interface setup
      retic_manual:
        control: hidden
        name: 'Manual Control'
        entities:
          - switch.retic_station_1_valve
          - switch.retic_station_2_valve
      
      retic_program1:
        control: hidden
        name: 'Program 1'
        entities:
          - input_boolean.retic_program1_enable
          - script.retic_program1_run
          - input_datetime.retic_program1_start_time
          - group.retic_program1_watering_days
          - group.retic_program1_run_times
        
      retic_program2:
        control: hidden
        name: 'Program 2'
        entities:
          - input_boolean.retic_program2_enable
          - script.retic_program2_run
          - input_datetime.retic_program2_start_time
          - group.retic_program2_watering_days
          - group.retic_program2_run_times

      retic_program1_watering_days:
        control: hidden
        name: 'Watering days'
        icon: mdi:calendar-multiple-check
        entities:
          - input_boolean.retic_program1_monday
          - input_boolean.retic_program1_tuesday
          - input_boolean.retic_program1_wednesday
          - input_boolean.retic_program1_thursday
          - input_boolean.retic_program1_friday
          - input_boolean.retic_program1_saturday
          - input_boolean.retic_program1_sunday

      retic_program2_watering_days:
        control: hidden
        name: 'Watering days'
        icon: mdi:calendar-multiple-check
        entities:
          - input_boolean.retic_program2_monday
          - input_boolean.retic_program2_tuesday
          - input_boolean.retic_program2_wednesday
          - input_boolean.retic_program2_thursday
          - input_boolean.retic_program2_friday
          - input_boolean.retic_program2_saturday
          - input_boolean.retic_program2_sunday

      retic_program1_run_times:
        control: hidden
        name: 'Run times'
        icon: mdi:camera-timer
        entities:
          - input_number.retic_program1_station1_run_time
          - input_number.retic_program1_station2_run_time

      retic_program2_run_times:
        control: hidden
        name: 'Run times'
        icon: mdi:camera-timer
        entities:
          - input_number.retic_program2_station1_run_time
          - input_number.retic_program2_station2_run_time
     
          
    #switch:                      # Solenoid control (will be signals to NodeMCU) NOT USED HERE BECAUSE CONTROL IS NOW VIA ESPHOMEYAML ADDON
    #  - 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: Reticulation Run Program 1     # start program 1 at designated time if it is enabled and today is selected as a watering day
        initial_state: 'on'
        trigger:
          platform: template
          value_template: "{{ states('sensor.time') == (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: sensor.retic_program1_watering_day
              state: 'True'
        action:
          - service: script.turn_on
            entity_id: script.retic_program1_run

      - alias: Reticulation Run Program 2     # start program 2 at designated time if it is enabled and today is selected as a watering day
        initial_state: 'on'
        trigger:
          platform: template
          value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program2_start_time.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
        condition:
          condition: and
          conditions:
            - condition: state
              entity_id: input_boolean.retic_program2_enable
              state: 'on'
            - condition: state
              entity_id: sensor.retic_program2_watering_day
              state: 'True'
        action:
          - service: script.turn_on
            entity_id: script.retic_program2_run


    script:
      retic_program1_run:             #run retic program 1 through each station for selected time
        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_2_valve
          
      retic_program2_run:             #run retic program 2 through each station for selected time
        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_2_valve

EDIT: I just tried to fix an error and it looks like the forum isnt showing the correct indentation…