Turn off repeat automation

Hello.
I have several automations and I only want them to run if there was a different automation running before, but not the same one. Tried to introduce a check for the last_triggered state, but the automations keep repeating. Can you help me with this?

- id: auto1
  alias: auto1
  trigger:
  - platform: numeric_state
    entity_id: sensor.average_pm2_5
    below: '11.5'
    for:
      minutes: 10
  condition:
  - condition: not
    conditions:
    - condition: state
      state: ''
      attribute: last_triggered
      entity_id: automation.auto1
  action:
  - service: notify.telegram_channel
    data:
      message: "{{trigger.to_state.state}}."
  mode: single

- id: auto2
  alias: auto2
  trigger:
  - platform: numeric_state
    entity_id: sensor.average_pm2_5
    above: 12.5
    below: '34.5'
    for:
      minutes: 10
  condition:
  - condition: not
    conditions:
    - condition: state
      entity_id: automation.auto2
      state: ''
      attribute: last_triggered
  action:
  - service: notify.telegram_channel
    data:
      message: "{{trigger.to_state.state}}."
  mode: single

Thank You!

I’m 3 months out of newest trics but one would be to create input_booleans.

Own boolean for each automation. When automation is triggered it will turn on this boolean. At the same time it turns off other automation booleans.

Then in condition it checks if the boolean is on or off.

The logic can be built the other way around as well. Depends how you want to name it e.g. input_boolean.allow_run_auto1 or input_boolean.has_triggered_auto1… you get the point I think?

1 Like

Yes, I got the idea. Don’t you have an example with this setting? I am new to this business.

Create as many input_boolean helpers as needed (in the configuration menu).
Lets use these as an example: input_boolean.allow_auto1, …allow_auto2, …allow_auto3.

I’m skipping most of the automation as writing with a phone.

For the first one, auto1

trigger:
   ...
condition:
- platform: state
  entity_id: input_boolean.allow_auto1
  state: on
action:
- service: input_boolean.turn_off
  data:
    entity_id: input_boolean.allow_auto1
- service: input_boolean.turn_on
  data:
    entity_id: 
    - input_boolean.allow_auto2
    - input_boolean.allow_auto3

The second automation similiarly by having input_boolean.allow_auto2 in the condition and so on.

1 Like

All work with some little changes. Thank You.
My code:

- id: pm25_green
  alias: pm25_green
  trigger:
  - platform: numeric_state
    entity_id: sensor.average_pm2_5
    below: '11.5'
    for:
      minutes: 10
  condition:
    condition: state
    entity_id: input_boolean.pm25_1
    state: 'on'
  action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.pm25_1
  - service: input_boolean.turn_on
    entity_id:
    - input_boolean.pm25_2
    - input_boolean.pm25_3
    - input_boolean.pm25_4
    - input_boolean.pm25_5
  - service: notify.telegram_channel
    data:
      message: "<b>{{trigger.to_state.state}}</b>.
  mode: single