Manual Trigger fails when used with a Trigger ID and a condition

Why does this fail to execute on a manual Run Actions ? It shows in the traces that it executed but somehow the manual trigger fails to pass the conditions. If I remove the condition it executes correctly.

alias: HUBs - Testing Manual Triggers
description: Testing Trigger
triggers:
  - trigger: event
    event_type: ""
    id: Manual Trigger
  - event: start
    id: HA startup
    trigger: homeassistant
conditions: []
actions:
  - if:
      - condition: or
        conditions:
          - condition: trigger
            id:
              - Manual Trigger
              - HA startup
    then:
      - data:
          entity_id: media_player.office_display
          url: http://192.168.1.110:8123/bed-m/default_view
          force: true
        action: dash_cast.load_url
        enabled: true
    enabled: true
mode: single

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Because the Trigger Condition has nothing to check.

Your automation’s two triggers have id variables but they’re defined only when the automation is triggered by one of its two triggers.

When you execute the automation via Run Actions, only the actions are executed, not the triggers. So there are no id variables defined and the Trigger Condition can’t check them (so the if statement evaluates to false and the dash_cast.load_url action is not executed).

tl;dr
You cannot test an automation’s actions using Run Actions if they refer to a trigger’s id.


For future reference, all of this is explained in Troubleshooting your automation.

Note that any trigger ID used in your triggers will not be active when you test this way. The Trigger ID or any data passed by in the trigger data in conditions or actions can’t be tested directly this way.

Thanks for the insight.
Would you be able to explain what the event_type: setting is used for in the following snippet. I couldn’t find any clues in the help file.

alias: HUBs - Testing Manual Triggers
description: Testing Trigger
triggers:
  - trigger: event
    event_type: ""
    id: Manual Trigger

event_type is exactly what it sounds like, it’s a string that identifies the type of event that will fire that trigger. You can use any string you want. It is best practice to avoid using any of the built-in event types.

There are different ways to use event types. Some users prefer to have a more general event_type then use event_data to make it specific to this automation. What you use as the data in event_data is also completely up to you.

alias: HUBs - Testing Manual Triggers
description: Testing Trigger
triggers:
  - trigger: event
    event_type: my_custom_event
    event_data:
      entity_id: automation.hubs_testing_manual_triggers
    id: Manual Trigger

While other users prefer to just have a specific event type for each automation

alias: HUBs - Testing Manual Triggers
description: Testing Trigger
triggers:
  - trigger: event
    event_type: my_custom_automation_hubs_testing_manual_triggers
    id: Manual Trigger

Please note that an event_type is required for you to actually fire that trigger from the Events tool, so your original trigger with an empty string as the value for event_type will not work.

So I am assuming the use case for Manual Triggers is unrelated to testing and more as a way to call an event as a sub-routine.

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title indicating the issue has been resolved. This will help other users find answers to similar questions.


If you intend to use an Event Trigger for the purpose of testing your automation, you can set event_type to a string of your choosing (as per Didgeridrew’s explanation). Then use Developer Tools → Events to fire your custom event.

All this to say that Run Actions is unsuitable for testing actions, or script variables, that refer to the trigger object (such as trigger.id, trigger.to_state.state, etc) because this object is undefined when Run Actions is executed.

I’m not sure about the timeline… but no, I doubt that manual Event triggers were developed for the explicit purpose of testing automations. In addition to the event tool Taras mentioned above, events can be raised and consumed by script actions as well as triggers.

But they can be a tool for testing and sometimes they are the only option if you use trigger-based conditions or templates.