Problem calling services using automation.turn_on

Good day I am trying to do some simple exercise to use automation.turn_on to call an automation from another automation. but, for some reason I cannot get it to work. This automation is supposed just to call trial_air_purifier that turn on a purifier.
I tested separately trial_air_purifier and is working properly.
Both automations are created using the visual editor.
Can you help me to understand what am I doing wrong?

alias: Trial_Call_air_Purifier_Automation
description: ""
trigger: []
condition: []
action:
  - service: automation.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: automation.trial_air_purifier
mode: single

A couple things - you’re using an automation where you really want a script, and “turning on” an automation doesn’t cause it to run, it just enables the trigger. Seems like you just want a script that turns on your air purifier, then call it from where you want.

2 Likes

As noted above using an automation to start another automation is usually bad practice.

But if you really want to do as you asked then use “automation.trigger” instead of “automation.turn_on”.

turning an automation on or off only enables or disables the automation. it doesn’t tell the automation to actually run the actions.

just be aware that triggering an automation this way will completely disregard any conditions in the manually triggered automation.

2 Likes

Thank you. Reading the difference between scripts and automations now. Will give it a go

2 Likes

thank you for clarifying. Will try “automation.trigger” as suggested.

Thanks for the clarifications.
I think I got it. automation.trial_air_purifier hasn’t any trigger in it, so automation.turn_on has nothing to enable.
I replaced automation.turn_on with automation.trigger, that works.

Concerning the scripting suggestion, I need to read a bit more.

1 Like

Scripts are essentially automations without triggers. You can literally copy and past the action part of an automation into a script and vice-versa.

2 Likes

All clear now. All working. thank you for the explanations.