09-02-2023 09:54 AM
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!
09-02-2023 10:34 AM - edited 09-02-2023 10:36 AM
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.
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
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
09-02-2023 11:34 AM
Pretty good idea, I also had it. In my automations it does not work sadly, did you manage to get it working properly?
09-02-2023 07:52 PM
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.
09-03-2023 01:16 AM
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!
09-03-2023 05:41 AM
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.
09-03-2023 06:40 AM
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!
09-22-2023 05:17 AM
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!!!