Automation condition when triggered programmatically

Hi all!
I have run into an interesting issue (or maybe I just don’t “get it”).

I have an automation running every minute. If the time of day is between 8:30 am and 6pm, and if my weather forecast sensor predicts 25°C or more for today and if I’m awake (a Boolean set everytime I say “ok google, good morning”, as I don’t want the covers in the bedroom to move if I’m still asleep past 8:30am), it will partially close the roller shutters. Otherwise, nothing should happen.

The trigger for this is time, and it is triggered every one minute.

In order to avoid unnecessary roller shutter travel, I wish to run this automation along with another sciprt ( the “ok google, good morning” script). So when I have in my script:

  - data:
      entity_id: automation.summertime_warmness
    service: automation.trigger

it does trigger the automation, bypassing said automation’s condition, and will partially close my shutters even if the forecasted temperature condition doesn’t match.

How could I apply the automation’s condition even when the automation is programmatically triggered, without having to insert the same condition in my “good morning” script?

Thank you all for your help!

If you trigger it, it is because you want to trigger it. The condition is ignored.

thank you nickrout!

It doesn’t make sense, though. Shouldn’t the condition be like a centralized way of managing whether the content of the automation should be ran or not? It seems redundant and counterproductive to have the condition both in my script and in my automation.

I mean, the triggering should be ignored since it has been triggered manually (or programmatical), but not the rest of the automation (conditions, actions, etc.)

That is not the way it works.

I am not sure what you are trying to do by the way. You seem to only want the shutters to open when you get up. Run it all from the good morning script. Or do I miss something?

Move the condition into the action. This will ensure it is evaluated even if the automation is triggered using the automation.trigger service.

From the documentation:

Conditions can also be part of an action. You can combine multiple service calls and conditions in a single action, and they will be processed in the order you put them in. If the result of a condition is false, the action will stop there so any service calls after that condition will not be executed.

1 Like

Hi, Thanks for the reply!
So from:

  - entity_id: sun.sun
    platform: state
  condition:
  - condition: template
    value_template: '{{ ((now().hour >= 8 and now().hour <= 18 ) and (states.variable.is_asleep.state == "False") and (states.sensor.max_temperature_today.state | int)>=25) }}'
  action:
  - data: {}
    service: python_script.set_state
    data_template:
      entity_id: variable.bedroom_cover_target_position
      state: '60'

to :

  trigger:
  - entity_id: sun.sun
    platform: state
  action:
  - condition: template
    value_template: '{{ ((now().hour >= 8 and now().hour <= 18 ) and (states.variable.is_asleep.state == "False") and (states.sensor.max_temperature_today.state | int)>=25) }}'
  - data: {}
    service: python_script.set_state
    data_template:
      entity_id: variable.bedroom_cover_target_position
      state: '60'

Is that what you’re suggesting?

So when I wake up in the morning, I want my shutters to open.
Throughout the day, if today’s max temperature is 24°C or above, I want my shutters to be lowered, as to reduce sun exposure.
What I want to avoid, is for me shutter to open all the way up in the morning, then moments later, go back down to, what I call, “summertime warmness” position. I want it to go directly to the “summertime warmness” position (60% shut) instead of going from 100% shut to 0% then back down to 60%.

And as the forecast might change throughout the day, I need to have this “summertime warmness” automation monitoring said forecast through the day.