Help with automation of sprinklers by season

Hi,
I am very new to HA and have got myself tangled trying to work out a way of automating my garden sprinklers so I am seeking your expert advice.
The overall ‘when’ to turn them on will be a schedule of some sort. And only one at a time - for water flow reasons
I cant conceptualise how to deal with the 2 dimensional nature of the duration they should be on for which varies by season

Device          Spring/Autumn  Summer   Winter
Ferns              10             18      3 
Veg2                8             15      3 
Veg1               20             20      3 
GeneralWhite        5              7      3 
GeneralGreen        5             15      5

And these are not actuually devices? entities? in HA. There is a 2nd Raspberry with a relay hat that does the physical switching
This reacts to Mqtt messages sent by HA and, practically speaking, only has 2 commands
watering/Ferns (Yellow)/ON
watering/Ferns (Yellow)/OFF

I setup a dropdown helper to define the current ‘season’. I think is accessed like
{ states("input_select.watering_season_2") }
I would prefer the durations to be in a variable of some kind rather than buried in code as they do get tinkerred with a bit depending actual rainfall
so I thought of 15 variables

Spring/Autumn/Ferns         10  
Spring/Autumn/GeneralGreen  5
Spring/Autumn/GeneralWhite  5
Spring/Autumn/Veg1          20
Spring/Autumn/Veg2          8
Summer/Ferns                18
Summer/GeneralGreen         15
Summer/GeneralWhite         7
Summer/Veg1                 20
Summer/Veg2                 15
Winter/Ferns                3
Winter/GeneralGreen         5
Winter/GeneralWhite         3
Winter/Veg1                 3
Winter/Veg2                 3

but then the automation looks messy to me. Allowing one for each area eg ‘Ferns’
In pseudo code it would be

    trigger - schedule
    condition - water is needed
    action 
        send 'ON' mqtt message
        if { states("input_select.watering_season_2") } = 'Spring/Autumn'
            delay { states("input_select.Spring/Autumn/Ferns") } minutes
        if { states("input_select.watering_season_2") } = 'Summer'
            delay { states("input_select.Summer/Ferns") } minutes
        if { states("input_select.watering_season_2") } = 'Winter'
            delay { states("input_select.Winter/Ferns") } minutes
        send 'OFF' mqtt message

If I had a database it would be simple
select duration where season = { states(“input_select.watering_season_2”) } and device = me

Thanks for any advice
JC

If you don’t mind relying on Internet connectivity, what about using a calendar to schedule the activities? For example, if you integrate a Google calendar called “Watering”, you will get an entity called “calendar.watering”, and the “message” attribute will be the subject from the calendar event. This could either be the whole MQTT topic to send, or just “Ferns”. Then you just need to create the relevant repeating calendar events that have the correct duration, and an automation to send the start and stop MQTT messages when the event occurs (there’s an example of doing this to turn lights on and off on the page I linked).

Thanks Michael, I will have a look at this tomorrow. Something tells me it doesn’t help with 2 dimensional matrix; but it does introduce me to the concept of Event having a start and an end.

I was thinking you’d create separate repeating events for each season, so Ferns for spring that lasts 10 minutes, and summer that lasts 18 minutes, etc. The downside of this is the event can only repeat on one cycle - for example daily between two dates; but not daily between two dates every year.

I suppose you could create a calendar named for each season, and then have the event repeat every day of the year (or every Monday, Wedesday, Friday or whatever your schedule is). Then on the HA side, only respond to events for the right season. So then you would be triggering for events from calendar.winter every day of the year, but ignoring them unless it was actually winter. Same for the other seasons.

I’m sure others have solved the problem. Personally I water my garden based on recent weather and total rainfall within the last week, but I only have two regions and I don’t bother adjusting the duration (although it sounds like a good idea).

In the end for this 1st cut I have selected to use 15 individual, simple, automations.
That is one for each of the 3 ‘Seasons’ by 5 regions.
And these have fixed daily times so no need for the Calendar.
Also the slave takes care of its own timeouts and safety stops so I am not worried about the possible complications of long delay times.

alias: Watering Spring/Autumn/Ferns
description: Trigger Watering Spring/Autumn/Ferns ON and OFF
trigger:
  - platform: time
    at: "18:33:00"
condition:
  - condition: state
    entity_id: input_boolean.watering_needed
    state: "on"
  - condition: state
    entity_id: input_select.watering_season
    state: Spring/Autumn
action:
  - service: mqtt.publish
    data:
      topic: watering/Ferns-(Yellow)/ON
  - delay:
      hours: 0
      minutes: "{{ states('input_number.w_spring_autumn_ferns') | int }}"
      seconds: 0
      milliseconds: 0
  - service: mqtt.publish
    data:
      topic: watering/Ferns-(Yellow)/OFF
mode: single