Manually triggered automation: action is run even if conditions are not met

I’m preparing something like a home-reset script, just to be able to reset “on the go” all my configuration switches/booleans/inputs to “default” values. why? long story short: I’ve got few light scenes automations based on for example: day of the week, hour, people presence etc. but also I can override them manually - and after that, my home-reset can bring everything back to order [well, in theory at least]. ok, now you know the background.

to manage that, my home-reset script will contain few “manual” triggers - let’s say something like this:

      - service: automation.trigger
        entity_id: automation.weekend_mode
      - delay:
        seconds: 2
      - service: automation.trigger
        entity_id: automation.morning
        ... (and so on)

automation.weekend_mode normally is triggered on midnight, and without the conditions part, I jump to service_template, where input_boolean.weekend is set on or off according to few ifs that use now().isoweekday(). all works fine, even if triggered manually.

now the fun part. automation.morning triggers at two morning hours (one for weekend, one for other days) and checks time conditions combined with weekend_mode, to set an input_select field to some option [the very same thing is made with other automations: evening, night etc.]. here’s the code:

      - platform: time
        at: "6:30"
      - platform: time
         at: "9:00"
      condition: or
        - condition: and
            - condition: time
              after: "6:30"
              before: "9:30"
            - condition: state
              entity_id: input_boolean.weekend_mode
              state: "off"
        - condition: and
            - condition: time
              after: "9:00"
              before: "11:00"
            - condition: state
              entity_id: input_boolean.weekend_mode
              state: "on"
      - service: input_select.select_option
          entity_id: input_select.part_of_the_day
          option: "morning"

          (...) and so on, other automations with other parts of the day

everything seems to be working fine when triggerred naturally, during the day. but when I trigger the automation via script, actions are executed no matter if conditions are met or not. and that’s wrong, right? or maybe I did some mistake and that’s the reason hassio bypasses the conditons? or I did not understood the way triggering and conditioning works? :wink:

can you throw me some hints?

Move the conditions and make them the first step under action. Manually triggering just runs the actions regardless of triggers and conditions.


thank you! that indeed worked :slight_smile:

I didn’t know that triggering the automation by hand overrides the conditions. I thought it’s like “hey you automation! you’ve been trigerred, now check the conditions!” :wink:

lesson learned.

(I know this thread is a bit old, but hopefully this is relevant.)

I think that this is both a functional and documentation problem. The docs go into great lengths to describe the difference between trigger and conditions, yet the “trigger” function in the UI has different semantics. I would think that the trigger function should either be renamed “run” or something similar in the UI or there should be an explicit mention in the Automations section that using the UI to “trigger” an automation will always run the actions.

I’m happy to propose a change to the documentation via github pull-request if people think it may be valuable.

1 Like

I’ll vote the functional option - I mean, if automation has triggers, conditions and actions it should be obvious, that manual triggering the automation just kicks it to check it’s conditions and then run actions if all are met.
if the manual triggering skips the conditions they are almost obsolete, as they are non-functional to me. so I guess that some changes should be done in the way of executing automations [by hand - especially]

right now I moved all my conditions in all my automations to the actions part, so I can still test them when manually triggered.

1 Like

I agree that this should definitely be changed to ‘run’ rather than ‘trigger’. The wording doesn’t really make sense. I was just checking my automation manually and the condition was being ignored, so this post saved me a lot of frustration, thanks!


So is this still the case?
Is it supposed to be like this?

Is there a bug on Github?

it is still a case but I think it won’t be considered as bug. to be honest - I’m so happy with moving conditions to the action part, hell, even into templates part [that gives more versality than regular conditions] that I stopped bother about that…

Has this changed??? I just tried running an automation from the UI and the conditions were evaluated…

didn’t used that for a bit, but AFAIR there’s a checkmark somewhere in the UI now that you can choose if conditions have to be evaluated or not

Sorry, disregard my post!! It was a blonde moment!
I was looking at the trace which was evaluating conditions but just now realized that I am using event: state_changed which calls the automation a lot in the 5 or 10 seconds it took me to switch screens and look at it thus I could not see my manual invocation trace in the 5 that HA keeps track of…