rgc99 / irrigation_unlimited

♒Irrigation controller for Home Assistant
MIT License
333 stars 49 forks source link

Running multiple sequences one after another, without specifying the time from 2nd sequence onwards #188

Open evercape opened 1 month ago

evercape commented 1 month ago

Hi Robert,

I like to group certain sprinkler zones by sequences (alternatively individual controllers) since it gives a better visual overview, and also allows me control those sequences (or controllers) at once using the UI of the companion card. In addition, seasonal schedules of run times typically apply to those group of sprinkler zones.

For instance, all lawn zones should be under "LAWNS", all the little drip line around the trees under "DRIPLINE TREES" and so on.

In an ideal case scenario, I would like to set the first sequence start time (ie sunrise +15) with its schedule to maybe cycle a few times 5 minutes or so through each zone, and then move to the next sequence.

However, the documentation prescribes a start time for each sequence.

As a work around, I could manually calculate the maximum total time of each sequence, and add that plus a bit to the first sequence start time in order to make sure that there is ample time for the first sequence to run, before the second sequence commences, and so on.

Is there any other cleve way to group either zones in sequences or via individual controllers and have them just run one after another? I went through the documentation (which has gotten very detailed and long!) but I can't come up with a clever solution.

Below is my yaml for multiple sequences, but each requiring a start time:

  irrigation_unlimited:
    controllers:
      - name: Benguela
        zones:
          - name: "Courtyard East" #01
            entity_id: switch.irr01_courtyward_east
          - name: "Driveway East" #02
            entity_id: switch.irr02_driveway_east
          - name: "Boundary Top West" #03
            entity_id: switch.irr03_boundary_top_west
          - name: "Driveway West" #04
            entity_id: switch.irr04_driveway_west
          - name: "Berms Trees" #05
            entity_id: switch.irr05_berms_trees
          - name: "Top of Berms" #06
            entity_id: switch.irr06_top_of_berms
          - name: "Guest House Deck" #07
            entity_id: switch.irr07_guest_house_deck
          - name: "Courtyward West" #08
            entity_id: switch.irr08_courtyward_west
          - name: "Lawn South" #09
            entity_id: switch.irr09_lawn_south
          - name: "Lawn North" #10
            entity_id: switch.irr10_lawn_north
          - name: "Bed Lawn / Back Braai" #11
            entity_id: switch.irr11_bed_lawn_and_back_of_braai
          - name: "Front Pool" #12
            entity_id: switch.irr12_front_of_pool
          - name: "Dripline Trees" #13
            entity_id: switch.irr13_dripline_trees
          - name: "Dripline Embankment" #14
            entity_id: switch.irr14_dripline_embankment
        sequences:
          - name: "Lawns"
            duration: "00:05"
            repeat: 4
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, wed, fri]
                month: [oct, nov]
            zones:
              - zone_id: 9
              - zone_id: 10
          - name: "Upper Driveway"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, wed, fri]
                month: [oct, nov]
            zones:
              - zone_id: 2
              - zone_id: 4
              - zone_id: 3
              - zone_id: 5
              - zone_id: 6
          - name: "Middle Terrace"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, wed, fri]
                month: [oct, nov]
            zones:
              - zone_id: 7
              - zone_id: 8
              - zone_id: 1
          - name: "Lower Pool"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, wed, fri]
                month: [oct, nov]
            zones:
              - zone_id: 11
              - zone_id: 12
          - name: "Dripline Trees"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, wed, fri]
                month: [oct, nov]
            zones:
              - zone_id: 13
              - zone_id: 14

If you have any ideas, or someone else, please let me know. Thanks Martin

rgc99 commented 3 weeks ago

It sounds like you want a type of sequence chaining. How about an automation that triggers when the sequence finishes and starts the next. Two ways to detect the end of a sequence; The state of the sequence entity goes from on to off or listen for the irrigation_unlimited_finish notification (there was new information added in the last release). Now fire a manual run on the next sequence but here is the trick, do not specify a time. It will calculate the default time.

evercape commented 3 weeks ago

Thanks Robert, that is exactly what I am trying to achieve. Automation is fine, however, isn't a start time always required?

Here is my setup code which works just fine, as I provide for ample time in between sequences:

  #IRRIGATION CONTROLLER
  irrigation_unlimited:
    history:
      span: 3
    refresh_interval: 15
    controllers:
      - name: Benguela
        enabled: true
        check_back:
          states: none
        all_zones_config:
          show:
            timeline: true
            config: true
          future_span: 6

        #Master Valve swith on/off before/after each zone run.
        preamble: 5 # Seconds
        postamble: 5 # Seconds
        entity_id:
          - switch.irr24_master_valve #master switch

        zones:
          - name: "Lawn North & South" #01
            entity_id:
              - switch.irr09_lawn_south
              - switch.irr10_lawn_north

          - name: "Driveway East" #02
            entity_id: switch.irr02_driveway_east
          - name: "Driveway West" #03
            entity_id: switch.irr04_driveway_west

          - name: "Top West Boundary" #04
            entity_id: switch.irr03_boundary_top_west
          - name: "Top of Berms" #05
            entity_id: switch.irr05_berms_trees
          - name: "Top Retaining wall" #06
            entity_id: switch.irr06_top_of_berms

          - name: "Courtyard East" #07
            entity_id: switch.irr01_courtyward_east
          - name: "Courtyward West" #08
            entity_id: switch.irr08_courtyward_west
          - name: "Guest House Deck" #09
            entity_id: switch.irr07_guest_house_deck

          - name: "Bed Lawn / Back of Braai" #10
            entity_id: switch.irr11_bed_lawn_and_back_of_braai
          - name: "Front of Pool" #11
            entity_id: switch.irr12_front_of_pool

          - name: "Dripline Trees" #12
            entity_id: switch.irr13_dripline_trees
          - name: "Dripline Embankment" #13
            entity_id: switch.irr14_dripline_embankment

        sequences:
          - name: "Lawns"
            duration: "00:25"
            repeat: 1
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, wed, fri]
                month: [oct, nov]
              - name: "Summer"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, tue, wed, thu, fri, sat, sun]
                month: [dec, jan, feb, mar]
              - name: "Autumn"
                time:
                  sun: "sunrise"
                  after: "00:15"
                weekday: [mon, fri]
                month: [apr, may]
            zones:
              - zone_id: 1

          - name: "Upper Driveway"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "01:00"
                weekday: [mon, wed, fri]
                month: [oct, nov]
              - name: "Summer"
                time:
                  sun: "sunrise"
                  after: "01:00"
                weekday: [mon, tue, wed, thu, fri, sat, sun]
                month: [dec, jan, feb, mar]
              - name: "Autumn"
                time:
                  sun: "sunrise"
                  after: "01:00"
                weekday: [mon, fri]
                month: [apr, may]
            zones:
              - zone_id: 2
              - zone_id: 3
              - zone_id: 4
              - zone_id: 5
              - zone_id: 6

          - name: "Middle Terrace"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "02:00"
                weekday: [mon, wed, fri]
                month: [oct, nov]
              - name: "Summer"
                time:
                  sun: "sunrise"
                  after: "02:00"
                weekday: [mon, tue, wed, thu, fri, sat, sun]
                month: [dec, jan, feb, mar]
              - name: "Autumn"
                time:
                  sun: "sunrise"
                  after: "02:00"
                weekday: [mon, fri]
                month: [apr, may]
            zones:
              - zone_id: 7
              - zone_id: 8
              - zone_id: 9

          - name: "Lower Pool"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "03:00"
                weekday: [mon, wed, fri]
                month: [oct, nov]
              - name: "Summer"
                time:
                  sun: "sunrise"
                  after: "03:00"
                weekday: [mon, tue, wed, thu, fri, sat, sun]
                month: [dec, jan, feb, mar]
              - name: "Autumn"
                time:
                  sun: "sunrise"
                  after: "03:00"
                weekday: [mon, fri]
            zones:
              - zone_id: 10
              - zone_id: 11

          - name: "Nature Reserve"
            duration: "00:05"
            repeat: 2
            schedules:
              - name: "Spring"
                time:
                  sun: "sunrise"
                  after: "04:00"
                weekday: [mon, wed, fri]
                month: [oct, nov]
              - name: "Summer"
                time:
                  sun: "sunrise"
                  after: "04:00"
                weekday: [mon, tue, wed, thu, fri, sat, sun]
                month: [dec, jan, feb, mar]
              - name: "Autumn"
                time:
                  sun: "sunrise"
                  after: "04:00"
                weekday: [mon, fri]
            zones:
              - zone_id: 12
              - zone_id: 13

Thanks Martin

rgc99 commented 1 week ago

I can see the problem. I have been experimenting with chaining sequences together with some success. The idea is to add a chain section to sequence. Something like

sequences:
  - name: "Lawns"
    ...
    chain:
      sequence_id: 2
      delay: '00:00:10'
  - name: "Upper Driveway"
    ...
    chain:
      sequence_id: 3

When the sequence finishes the time: parameter of the chained schedule is updated.