ESPHome: DIY Irrigation Controller With Internal Scheduler

HI @joaquin68 ,

I think you should add the initial state as suggested by @VikingBlod to avoid reboot loop

input_text:
irrigation_zone1_times:
name: Zone 1 Time Periods
initial: 01:00
irrigation_zone2_times:
name: Zone 2 Time Periods
initial: 01:00
irrigation_zone1_days:
name: Zone 1 Days of the Week
initial: Mon,Wed,Fri
irrigation_zone2_days:
name: Zone 2 Days of the Week
initial: Mon,Wed,Fri

EDIT: got it. I need to define once and the remove it to avoid issues with reboot

2 Likes

Hi @VikingBlod ,

how did you change the card?

I can’t make the slider working
image

and I would like to understand if you are able to insert the day and the time in the UI

input_text:
  irrigation_zone1_times:
    name: Zone 1 Time Periods
    icon: mdi:chart-timeline
  irrigation_zone1_days:
    name: Zone 1 Days of the Week
    icon: mdi:calendar-week
input_number:
  irrigation_zone1_duration:
    name: Zone 1 Duration
    icon: mdi:timer
    min: 2
    max: 60
    step: 2    

This is how I define the values. And the following is how I configured my Lovelace Yaml.

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: input_text.irrigation_zone1_days
        - entity: input_text.irrigation_zone1_times
        - entity: input_number.irrigation_zone1_duration
        - entity: sensor.zone_1_next_watering
      title: Backyard Zone 1 - Schedule
    - type: entities
      entities:
        - entity: switch.irrigation_zone_1
          secondary_info: last-changed
          name: Zone 1 Watering
      title: Backyard Zone 1 - Watering
    - type: history-graph
      entities:
        - entity: switch.irrigation_zone_1
      hours_to_show: 24
      refresh_interval: 0

The above gives me the following;

1 Like

Thank you!!!
I figured out that Entities card has the expected behavior VS the Entity card

i will play more now with your sample. thank you for sharing

1 Like

Hi,

I managed to configure it. Thank you all for this amazing job
I replaced the sonoff with an ESP32 and I control 6 zones with a relay board

I have 2 additional questions:

  1. if I want to run a zone more than one time the same day, should I configure the time with the comma separator? (eg. what I did in zone 2)

  2. In the ESP32 log I see this INFO Detected timezone 'CET' with UTC offset 1 and daylight savings time from 27 March 02:00:00 to 30 October 03:00:00, but on the scheduled time the zone doesn’t start. any idea on what I’m missing?

if i manually trig the switch (see Zone 1), sounds good

but the next irrigation is ignored
as you can see Zone 2 is not triggered, and Zone 3 schedule is wrong, it should be Thu not Mon

I tested both the timezone format, same issue

    timezone: Europe/Rome
    timezone: CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00

regards

EDIT. I think I found the first issue, Day and Time need a comma as separator without spaces

eg

Mon,Tue,Wed,Thu,Fri,Sat,Sun 
22:01,22:10

but the next irrigation still doesn’t toggle the switch :frowning:

1 Like

HI,

I understood the issue
when you replace the days name in the integration.h file to match your language, you have to put attention to the text specially to match the latest case (Today)

else if (day == "Tod") { //Today in English

because the substitution is taking only 3 char, you have to use only the first 3 char in your language

string day = time.substr(6,3).c_str(); //day text is added to original string

for English “Today” is “Tod”

// Converting days to week numbers, change text based on your Language
    if (day == "Mon" || day == "mon" || day == "MON") {
      next_wday = 2;
    } else if (day == "Tue" || day == "tue" || day == "TUE") {
      next_wday = 3;
    } else if (day == "Wed" || day == "wed" || day == "WED") {
      next_wday = 4;
    } else if (day == "Thu" || day == "thu" || day == "THU") {
      next_wday = 5;
    } else if (day == "Fri" || day == "fri" || day == "FRI") {
      next_wday = 6;
    } else if (day == "Sat" || day == "sat" || day == "SAT") {
      next_wday = 7;
    } else if (day == "Sun" || day == "sun" || day == "SUN") {
      next_wday = 1;
    } else if (day == "Tod") { //Today in English
      next_wday = time_wday;
    }
1 Like

HI @bremby Thank! I havent installed yet, i have to make a modification at pump shelter. I tested on my kitchen table :sweat_smile: everything was working but I dont remeber if I tested that specific function.

regards

@bremby hi again! if you define initial, every time you reboot HA it will set to that value. will lost you days or times settings.

Bye

@bremby guess what?? it´s me again :stuck_out_tongue_closed_eyes: delete initial from code

From my config.yaml

input_number:
  irrigation_zone1_duration:
    name: Duración Zona 1
    min: 0
    max: 30
    step: 1
    mode: slider
    icon: mdi:timer

Tell me if that works

Regards

Hi,

thanks for noticing this. Maybe because i am spanish speaker and in spanish today = “hoy”, just 3 letters so i didn’t have that problem when i modified irrigation.h

regards,

Hi,

I managed to make everything working and cover 6 zones

this is the configuration page

I also added 2 additional switches
one to stop all the schedules when they are running
image

- platform: template
    name: Stop All Zones
    id: irrigation_stop_zones
    icon: mdi:sprinkler-variant
    optimistic: true
    turn_on_action:
      - switch.turn_off: irrigation_channel_1
      - switch.turn_off: irrigation_channel_2
      - switch.turn_off: irrigation_channel_3
      - switch.turn_off: irrigation_channel_4
      - switch.turn_off: irrigation_channel_5
      - switch.turn_off: irrigation_channel_6
      - delay: 10s
      - switch.turn_off: irrigation_stop_zones

one to “suspend” the schedule (eg. you want to suspend the irrigation for a period of time, but you don’t want to clean the configurations or turn off the esp)

image

  - platform: template
    name: Irrigation Zone 1
    id: irrigation_zone_1
    icon: mdi:sprinkler-variant
    lambda: return id(irrigation_channel_1).state;
    optimistic: true
    turn_on_action:
      # Turn on if not disabled and not running
      if:
        condition:
          and:
            - lambda: return id(irrigation_zone_1_duration) > 0;
            - binary_sensor.is_off: ui_stop_irrigation_automation
        then:
          - switch.turn_on: irrigation_channel_1
    turn_off_action:
      - switch.turn_off: irrigation_channel_1

let me know what you think or if you have made additional configurations or have any suggestions

regards

2 Likes

Hi! great Job…i thinking about different season config, you dont need the same amount of water in autumn and winter, as in spring and summer.

Regards

1 Like

Hey all, thinking about giving this project a try. I notice the device used for switching is a Sonoff 4 Channel Pro R2. I don’t seem to be able to find one and the link in the blog article says it is out of stock.

Does anyone know if a Sonoff 4 Channel Pro R3 would work or is this something different again?

Also would this be suitable as a power supply?

Hi @currest2620,

I used an ESP32 module with an 8ch relay module:

LILYGO® TTGO T-Internet-POE ESP32-WROOM LAN8720A Chip Ethernet Adapter And Downloader Expansion Board Programmable Hardware - Module - Shenzhen Xin Yuan Electronic Technology Co., Ltd

ELEGOO Relay Module with Optocoupler for Arduino UNO R3 MEGA 2560 1280 DSP ARM PIC AVR STM32 Raspberry Pi – ELEGOO Official

The trick is adjusting the PINOUT definition with your board

Nice, though I would prefer to use a sonof four channel as the relays are built in.

Thank you for letting me know about the outdated Sonoff link (I am updating the link on my post). The R3 looks to be a direct replacement for the R2, so it should work the same.

Awesome. I’ll get one ordered. Thanks for the feedback.

Hello,

So I have everything configured but I’m running into an issue.
I have it scheduled for Saturday @05:53 and Monday @11:00. The next watering for zone 1 should say Monday @11:00 since the watering for Saturday has already ran but it’s showing Saturday @11:00.

Not sure why it’s not following the schedule.

Hi! @stinger that’s because the schedule is for every day, you can’t choose the time for each days… So, if you choose Saturday and Monday, and then you set it to run at 5 am and 11am, it will run those two days at those two hours :grimacing:

Thanks for the info. I’ll see what I can do to modify it to fit my needs.