Limit number of sequence repetitions

Hello,

is there a way to limit the number of repetitions of the following sequence loop?

waschmaschine_ansage:
  sequence:
    - condition: numeric_state
      entity_id: sensor.oeq1403217_current
      value_template: "{{ state.attributes.current }}"
      above: 10.0
      below: 40.0
    - condition: time
      after: '09:00:00'
      before: '21:00:00'
    - service: homematic.set_device_value
      data:
        address: NEQ1468231
        channel: 2
        param: SUBMIT
        value: "1,1,108000,6"
    - service: script.waschmaschine_ansage_loop
        
waschmaschine_ansage_loop:
  sequence:
    - delay:
        minutes: 5
    - service: script.waschmaschine_ansage

Currently it ends when the current of the washing machine is not between 10.0 and 40.0 mA or if the time is not between 9am and 21am. Can I add an additional condition that stops repeating after let’s say 10 repetitions?

Thanks in advance.

Yes, it would be easy to do that. Create a Counter. Add a condition that the counter value is less than 10. Then add a step after the conditions that increments the counter.

The question then becomes, what should allow the script to run again? I.e., something needs to reset the counter. Maybe you already have an automation that starts the script running, in which case, just add a step in the actions, before calling the script, that resets the counter.

1 Like