How to know if an automation fired?

Hiii everyone.

This is an automation example:

  trigger:
    - platform: time
      at: "00:00"
    - platform: time
      at: "02:00"
    - platform: time
      at: "10:00"
    - platform: time
      at: "20:00"

  condition:
    - condition: template
      value_template: "{{(states('sensor.meteonetwork_daily_rain')|int |default(0)) <= 30}}"
  action:
    [something]

Please remember that is an example.
In real life the “conditional” code is much more complex.

My goal is manage when the automation:

  1. is not yet triggered
  2. is not triggered (example for power problem)
  3. is triggered but not fired (for condition respect)
  4. is triggered and fired

So I thought I’d create a input_select for each trigger time :

test02:
    options:
      - automation fired
      - automation not yet triggered

At 00:00 time tha automation set the input_select to: automation not yet triggered

In this way I can manage points 1 and 4.
Points 2 and 3 remain unsolved for which the input select would always remain on: automation not yet triggered
Point 2 because the automation not start;
Point 3 because the automation trigger but not fire (It would be useful to create an attribute last_fired for the automation).

Do you know of any way to check if the automation has triggered but not fired without having to make an automation that checks the automation?

Thanks for the attention.

Just look at the trace.

There’s also the last_triggered attribute for when it actually ran.

My goal is manage not watch! :crazy_face:

It does not change if the automation trigger and fired and trigger and not fired

What does manage mean? The last_triggered attribute can be used to see if it hasn’t triggered since some other point in time. There are infinite things that can happen without triggering the automation. You cannot “manage” that.

Best I can think of is to make a list of all entities involved, and if any of them change and the automation does not fire, it must have been stopped by a condition. But still, I fail to see what it manages. What do you hope to accomplish?

Or stop using the condition block. use if else instead, and use tthe else to register when you didn’t do something.

In the example of the automation above I would like to be able to discriminate if the automation action (which is triggered by time)

  1. was not done (for example due to an electrical problem)
  2. was not done because it was raining too much at the time of the trigger.

Which is exactly what I wanted to avoid…

:ok_hand:

An automation’s last_triggered attribute indicates the time when the automation executed its actions. In other words, one of the automation’s triggers has fired and the automation’s condition has been met and the automation proceeds to execute its action. A trace is produced.

If one of the automation’s triggers fires but its condition is not met then last_triggered is not updated. A trace is produced. Beyond that, there’s no other other record of the event.

Thank you all for your attention

@Pico1965 First of all, your terminology is rather incorrect.
Point #1 cannot be determined:

  1. is not yet triggered
    and why would you want to know this?? If for some reason unbeknownst to me you do, you’d need another mechanism to check for example if the time is after 00:00 but before 02:00 then next execution should occur at 02:00. Same for after 02:00 but before 10:00, after 10:00 but before 20:00, after 20:00 but before 23:59:59.

As for points 2, 3 and 4, they should be worded like this:
2. was not triggered - I.e. HA was not running or restarting and the time trigger was missed
3. was triggered but did not complete execution (for condition respect)
4. was triggered and execution completed

Have a look at this example I put together which has two different ways of dealing with the 4 time triggers.

description: ""
mode: single
trigger:
  - platform: time
    at: "00:00:00"
    id: 12:00 AM
  - platform: time
    at: "02:00:00"
    id: 2:00 AM
  - platform: time
    at: "10:00:00"
    id: 10:00 AM
  - platform: time
    at: "20:00:00"
    id: 8:00 PM
condition:
  - condition: template
    value_template: "{{(states('sensor.meteonetwork_daily_rain')|int |default(0)) <= 30}}"
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - 12:00 AM
        sequence:
          - event: automation_00:00_triggered
            event_data: {}
          - event: automation_at_ 00:00_performed_this
            event_data: {}
          - event: automation_00:00_completed
            event_data: {}
      - conditions:
          - condition: trigger
            id:
              - 2:00 AM
        sequence:
          - event: automation_2:00_triggered
            event_data: {}
          - event: automation_at_2:00_performed_this
            event_data: {}
          - event: automation_2:00_completed
            event_data: {}
      - conditions:
          - condition: trigger
            id:
              - 10:00 AM
        sequence:
          - event: automation_10:00_triggered
            event_data: {}
          - event: automation_at_10:00_performed_this
            event_data: {}
          - event: automation_10:00_completed
            event_data: {}
      - conditions:
          - condition: trigger
            id:
              - 8:00 PM
        sequence:
          - event: automation_20:00_triggered
            event_data: {}
          - event: automation_at_20:00_performed_this
            event_data: {}
          - event: automation_20:00_completed
            event_data: {}
  - event: automation_performed_this_sequence
    event_data: {}
  - choose:
      - conditions:
          - condition: trigger
            id:
              - 12:00 AM
        sequence:
          - event: automation_at_00:00_completed
            event_data: {}
      - conditions:
          - condition: trigger
            id:
              - 2:00 AM
        sequence:
          - event: automation_at_2:00_completed
            event_data: {}
      - conditions:
          - condition: trigger
            id:
              - 10:00 AM
        sequence:
          - event: automation_at_10:00_completed
            event_data: {}
      - conditions:
          - condition: trigger
            id:
              - 8:00 PM
        sequence:
          - event: automation_at_20:00_completed
            event_data: {}

Just substitute your input_select(s) for the fire_event calls where needed.
Or, you can retain those fire_event calls and in another automation (or automations) you can listen for those events and update your input_selects, or whatever…

As for point #2, you’d need an automation triggered by homeassistant start:

  - platform: homeassistant
    event: start
    id: HA Start

and another choice option that figures out what to do in that case.
I.e. if time is after 00:00 but before 02:00 and input_select for automation_at_00:00 is not executed, then do those steps. Ditto for the next three time windows. Note though: when executed at 00:00, set input_select for 00:00 to triggered followed by executed. When 02:00 fires, it needs to set input_select for 00:00 back to not_triggered in addition to input_select for 02:00 to triggered and then executed, and so on and so forth.
It might be easier to have 4 different scripts of actions to perform (if there are different steps needed) for the 4 different time triggers and then the HA Start trigger can execute the appropriate script if the current time is after xx:xx but before xx:xx and the state of input_select shows not_executed.
If time < 02:00 and 00:00 is not_triggered then run that script of conditions and actions.
If time < 10:00 and 02:00 is not_triggered then run that script of conditions and actions
If time < 20:00 and 10:00 is not_triggered then run that script of conditions and actions
If time < 23:59:59 and 20:00 is not_triggered then run that script of conditions and actions
Then at 23:59:59 set then all to not_triggered.
The phases would be 1. not_triggered, 2. triggered, and 3. completed, then, rather than having a central condition to fail the automation steps to complete them, you’ll need to first perform an action of setting the input_select to triggered then followed by the conditional execution of desired actions ending with setting input_select to completed.

Strange that the board didn’t notify me of your comments.
I only saw them today by chance

Probably…
Sorry.

After Taras’s reply I moved all my (many) conditions under action and solved it.