Automation stopped working - trace says "Stopped because only a single execution is allowed"

I have an automation that stopped functioning lately. The trace states “Stopped because only a single execution is allowed.” No changes were made to the automation. I assume the issue is with the wait_for_trigger which I found/hobbled together from other automations here on the forum. The idea of the wait_for_trigger is to have the shades reopen once the sun’s elevation is high enough to not blind my eyes while sitting here at my desk. Any advice to resolve this?

- id: '22028368334373038'
  alias: entry blinds blinding sun so close the shade
  trigger:
  - platform: time
    at: 08:30:00
  - platform: time
    at: 08:45:00
  - platform: time
    at: 09:00:00
  - platform: time
    at: 09:15:00
  - platform: time
    at: 09:30:00
  - platform: time
    at: 09:45:00
  - platform: time
    at: '10:00:00'
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sun.sun
      attribute: azimuth
      above: '120'
      below: '137'
    - condition: numeric_state
      entity_id: sun.sun
      attribute: elevation
      below: '29'
      above: '10'
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    - condition: numeric_state
      entity_id: sensor.lightlevel_entryway
      above: 60
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.closedentry
  - wait_for_trigger:
    - platform: numeric_state
      entity_id: sun.sun
      attribute: elevation
      above: '30'
    continue_on_timeout: false
  - service: scene.turn_on
    target:
      entity_id: scene.daytimeentry

Don’t you use the mode of the automation?
I mean, I did not read and understand your automation thoroughly, sorry, I’m giving a hint (that might be not appropriate, sorry again)
Mode is described here, maybe you should select one or another?

I assumed that single, which it defaults to if not defined, is the accurate need here. Maybe I’m still too ignorant with this stuff?

1 Like

If you need single, it is perfectly fine.
But then, if the automation is triggered again while the previous execution is still waiting on one of the actions, like the wait_for_trigger, you’ll get the exception you described “Stopped because only a single execution is allowed.”

I’m always confused by the continue_on_timeout set to false because it is meant to abort the script but on the other hand, if true what does that mean? Execute the remaining actions?

I believe also that reaching 30 as elevation could take more or less time depending on the season and where you live. Might be the reason why the automation is triggered while the previous occurrence is still running?

The question is “Is it possible that waiting for the elevation to get to 30 is taking more than the 15 minutes before your next time platform trigger?”

Looking at your actions, I feel like restart should be fine, hear me out:

  - service: scene.turn_on
    target:
      entity_id: scene.closedentry

If it was done by the previous run, it should be fine to do it again, right (if your scene doesn’t include toggle service call)?

  - wait_for_trigger:
    - platform: numeric_state
      entity_id: sun.sun
      attribute: elevation
      above: '30'
    continue_on_timeout: false

Interrupting that one, if it was hanging in the previous run, is not important as this new run will restart and continue the waiting time.

 - service: scene.turn_on
    target:
      entity_id: scene.daytimeentry

This one will be executed, one day or another by one of the triggered instances (and if the elevation reach 30).

Why does the automation trigger at specific times instead of triggering based on the sun’s elevation and azimuth?

@Olivier1974 I think restart makes sense from what you describe.

@123 my ignorance. I tried to do that but it wasn’t working with two items as triggers. How best should I do that?

When you put more than one trigger, the automation starts if any of the trigger condition is met. See it as an or, not an and

Not sure about your exact requirements but this should give you an idea of how to structure it without relying on wait_for_trigger or the mode.

- id: '22028368334373038'
  alias: entry blinds blinding sun so close the shade
  trigger:
    - id: 'closedentry'
      platform: template 
      value_template: >
        {% set a = state_attr('sun.sun', 'azimuth') | int(0) %}
        {% set e = state_attr('sun.sun', 'elevation') | int(0) %}
        {% set l = states('sensor.lightlevel_entryway') | int(0) %}
        {{ 120 < a < 137 and 10 < e < 29 and l > 60 }}
    - id: 'daytimeentry'
      platform: numeric_state
      entity_id: sun.sun
      attribute: elevation
      above: '30'
  condition:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    - service: scene.turn_on
      target:
        entity_id: 'scene.{{ trigger.id }}'

Thank you both. I’ll play with it over the weekend and come back w/ any questions or to mark solutions, etc.

The solution of Taras is the best as it is replacing multiple events by one.
But template triggers is not always easy for beginners, don’t know your level in coding (btw, if you are wondering, this is Jinja2 language) and you can always test your code in

Developer Tools > Template