08-25-2023 07:07 PM
Hello,
I'm looking for a way to call an script from another script, I've created script to manage some stuff and now I want to call all those scripts in a single script.
08-25-2023 10:18 PM - edited 08-25-2023 10:19 PM
My approach is just a workaround in the current Google Home implementation.
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
12-20-2023 11:53 PM
Thanks for your suggestion. But it's not working well unfortunately. Seems like Google home mini can understand the "turn_off_the_air" query and I get a response like "Sorry, it looks like that thermostat hasn't been set up yet. You can do that in Assistant Settings.".
I'm trying to create some continuous reminder like following and would appreciate your help.
metadata:
name: Test
description: Test
automations:
- name: Ventilate office reminder
starters:
- type: time.schedule
at: 8:00
- type: assistant.event.OkGoogle
eventData: query
is: ventilate_office_reminder
actions:
- type: assistant.command.Broadcast
devices:
- Office speaker - Office
message: Remember to ventilate the office
- type: time.delay
for: 10min
- type: assistant.command.OkGoogle
devices:
- Office speaker - Office
okGoogle: ventilate_office_reminder
- name: Stop reminder
starters:
- type: device.state.OpenClose
device: Office Window - Office
state: openPercent
is: 100
actions:
- type: assistant.command.OkGoogle
devices:
- Office speaker - Office
okGoogle: Stop "Ventilate office reminder"
12-21-2023 06:02 AM
Multiple automations in a single script might not work normally currently, so maybe you can try to split it into two scripts (I know it's not elegant to do so ...).
You can check this link for more details.