Irrigation logic with ESP32 and relays

I have an ESP32 dev board with a 8 channel relay connected to it. The first two relays are connected to water pumps. I’d like to switch them with a logic. I set up a few helpers to be able to change the parameters from the UI, like:

  • input_datetime.pump1_start_time: it has only the time part like 16:00. This is the time in a day when irrogation is enabled from.

  • input_datetime.pump1_end_time: it also has only the time part like: 20:00. This is the time in a day when irrogation is enabled to.

  • input_number.pump1_cycles: int type, like 5. This shows that how many irrogation cycles should happen beetween the start and end time

  • input_number.pump1_duration: int type, like 30 (in seconds). This is the ON duration time of the relay

  • input_button.pump1_save_settings: a trigger to calculate the new start times of every cycle

start time: 16:00
end time: 20:00
cycles: 4
duration: 30

When i press a button I want to see the calculated start times:

cycle1: 16:00:00
cycle2: divided into equal parts, about 17:30
cycle3: divided into equal parts, about 18:30
cycle4: 19:59:30

Then an automation could use this to check when a cylce should start and after how many seconds (input_number.pump1_duration) should stop.

Do you think that this is a good way or can you recommend me something else?

There are some custom integrations on HACS that you might take a look at.
I’m using one for my irrigation solution also with a similar setup with esp32, esphome and a six channel relay board to program the irrigation cycles.

Irrigation custom integration

Thanks for the recommendation. I checked it and it looks quite useful but I think this is not what I need. I have to turn on the pump 5 or more times a day and I need also the function to be able to set a time period when my cycles can run. I didn’t find any of this in this controller.