Trigger automation from other automation while checking conditions

Hi,

Is there a way to trigger automations from other automations while checking/validating the conditions of the 2nd automation ?

This is done a lot in e.g. HomeSeer to get a grip in the order in which automations are executed. But it also helps in cleaning up the automations if you have multiple triggers with different conditions.

Best regards,
Deva

Rather than call ing the automation.trigger service which will disregard the trigger and conditions in the 2nd automation you could set an input boolean using the input_boolean.turn_on service. Add a state trigger for this input boolean in the second automation.

Other options I can think of are adding an mqtt trigger to the second automation. Or calling a script rather than the second automation (you can use conditions in scripts).

Yeah, that’s rather a suboptimal solution that i already had in mind :frowning:

Put the conditions for the second automation in the action block instead of the condition block.

trigger:
  - SOME TRIGGER 
condition:
  condition: state 
  entity_id: sensor.foo
  state: 'bar' 
action:
  - SOME ACTION

Becomes

trigger:
  - SOME TRIGGER 
action:
  - condition: state 
    entity_id: sensor.foo
    state: 'bar' 
  - SOME ACTION

Of course this will mean that you can’t use automation.trigger to fire the actions in spite of the conditions any more.

1 Like

But that does not work if i want to do multiple things based on different conditions …

Neither does a condition block.

You need to look at service_template and data_template.