cancel
Showing results for 
Search instead for 
Did you mean: 

triggering automation with automation

smarthomie
Community Member

Hi everyone,

 

I'm planning to make an automation that triggers two other automations, which have different conditions in order to create an if-else situation. Does anyone know how to do that?

 

Thank you!

7 REPLIES 7

EricTsengTy
Community Member

My approach is just a workaround in the current Google Home implementation.
The implementation below is written by Scripted Automation, but it can also be implemented with a normal routine.

Callee

Add a starter with the type "assistant.event.OkGoogle" and set the property "is" to a function name. It's better that the function name is not a valid English sentence. For example, I prefer "turn_off_the_tv" instead of "Turn off the TV".

 

 

metadata:
  name: Turn off the Air
  description: Simply turn off the Air via scene in third party app

automations:
  starters:
    - type: assistant.event.OkGoogle
      eventData: query
      is: turn_off_the_air

  actions:
    - type: device.command.ActivateScene
      activate: true
      devices: Power off Air

 

 

 Caller

Now in the script you wanna call the above script, you can trigger the script by specifying the function name with "assistant.command.OkGoogle".

 

 

  actions:
    - type: assistant.command.OkGoogle
      okGoogle: turn_off_the_air
      devices: Nest - Living Room

 

 

 

Pretty good idea, I also had it. In my automations it does not work sadly, did you manage to get it working properly?

Yep, it works (at least when I test it last week).

Maybe you can provide your script then I can help you check it.

It's also possible that I miss something.

That's cool! My scripts look like that:

 

Caller:

metadata:

name: Untitled description: Caller

automations:

starters:

type: assistant.event.OkGoogle

eventData: query is: start my test routine

actions:

type: assistant.command.OkGoogle okGoogle: this_is_a_test devices: Badezimmer - Badezimmer

 

Callee:

metadata:  name: Untitled2 description: Callee  automations:  starters:  type: assistant.event.OkGoogle eventData: query  is: this_is_a_test  actions:  type: assistant.command.Broadcast  message: it works devices: Badezimmer Badezimmer

 

Thanks for your help!

Feels like I can't find any obvious problem in your script. I only notice that you don't have the dash "-" in front of the keyword "type", but I'm not sure whether it's just a copy/paste problem.
Btw, you can use the "Insert/Edit code sample" to format your script to make it more understandable.

EricTsengTy_1-1693744578148.png

 

Thanks for the tip! I found a solution called "Google Home Playground". With that developer function you can create fake lights or other smart home devices. With the on/off states of them you can trigger other automations with an automation, works perfectly fine!

I also had the OkGoogle idea, but it doesn't want to work for me either.

The solution with the 'Google Home Playgroud' works perfectly. Thanks!!!