cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple automations in single script sometimes breaks when using `assistant.event.OkGoogle` starter

Alphabet
Community Member

I am trying to write a script in the Google Home Script Editor that uses multiple automations inside the `automations` struct as described at the bottom of the article "Automation". 

Here is a simple example that is modified from the example in the documentation article:

 

metadata:
  name: Test MultiAuto
  description: Testing multiple automations in a single script.

automations:
  - name: At 11:40pm, turn on light.
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: help me eat
    actions:
      type: device.command.OnOff
      devices: Sofa - Living Room
      on: true
  - name: At 11:38pm, turn off light and broadcast "time to sleep"
    starters:
      type: time.schedule
      at: 2:40 AM # HH:MM XM (12 hours format). Adjust time as needed
    actions:
      - type: device.command.OnOff
        devices: Sofa - Living Room
        on: false
      - type: assistant.command.Broadcast
        message: time to sleep
        devices: Living Room Display - Living Room

 

 

When I say "Hey Google, help me eat" it doesn't always work. For the first 20 minutes of trying to write and debug the script it wasn't working. It finally started just working oddly for a while. But then I changed the `is:` to a new query such as "help me test" and it was back to saying it doesn't understand. However, saying the previous query "help me eat" made it give no response like it was working, but the actions didn't actually execute. After another 10 minutes of it not responding to the new "help me test" query, I changed the script back to "help me eat" and saved it, and then instantly the assistant picked up "help me eat" again and executed the respective action.

The only thing I can think of right now is that the `assistant.event.OkGoogle` starter query takes time to fully propagate in the system and recognize the query?

I have a more complex script with 4 automations each with their own `assistant.event.OkGoogle` starter, and none of those sets of starters ever register and execute their respective actions. I'd love for this to work.

I am using a Nest Hub Max for testing the script. That's what I am saying "Hey Google, help me eat" to. Hopefully this helps, thank you!

 

24 REPLIES 24

Prafulla
Googler
Googler

Thanks for sharing your experience @Alphabet. assistant.event.OkGoogle propagation should not take time. To isolate the problem, can you try a very simple script like one below and use bunch of unique queries (e.g. "test automation 1", "test automation 2" etc.) to run the automation? Please share if propagation is taking time when you update the query.

 

metadata:
  name: Test automation
  description: Test automation

automations:
  starters:
    - type: assistant.event.OkGoogle
      eventData: query
      is: Test automation 1 # Then replace with Test automation 2 etc.

  actions:
    - type: assistant.command.OkGoogle
      okGoogle: Tell me the weather
      devices: <your speaker name from autocomplete>

 

Hey @Prafulla,

thanks for the quick response! I don't have any issues with using the assistant.event.OkGoogle in scripts with single automations.

Here is a custom script that has been working fine for the past 2-3 days. I can say "Hey Google, fix upstairs bathroom" or "Hey Google, Fix the upstairs bathroom" and it executes properly every time.

 

# --------------------------------------------------------------------------------------------- #
# On the Nanoleaf Matter A19 bulbs, if the power is accidentially cut for less than ~3 seconds,
# their state is sometimes misrepresented. This automation refreshes them immediately if needed.
# --------------------------------------------------------------------------------------------- #
metadata:
  name: Fix Upstairs Bathroom
  description: Fixes the upstairs bathroom lights states in the event of accidentally cutting the power (light switch).

automations:
  starters:
    - type: assistant.event.OkGoogle
      eventData: query
      is: Fix Upstairs Bathroom
    - type: assistant.event.OkGoogle
      eventData: query
      is: Fix the Upstairs Bathroom

  actions:
    - type: device.command.OnOff
      on: true
      devices:
        - Right Light - Upstairs Bathroom
        - Left Light - Upstairs Bathroom
    - type: time.delay
      for: 1sec
    - type: device.command.OnOff
      on: false
      devices:
        - Right Light - Upstairs Bathroom
        - Left Light - Upstairs Bathroom

 

Just to be sure, I modified my script from my original post to match your script:

 

metadata:
  name: Test MultiAuto
  description: Testing multiple automations in a single script.

automations:
  starters:
    - type: assistant.event.OkGoogle
      eventData: query
      is: Test automation two # Then replace with Test automation 2 etc.

  actions:
    - type: assistant.command.OkGoogle
      okGoogle: Tell me the weather in london
      devices: Living Room - Living Room

 

This worked instantly, though I had to change the integer "1"/"2" to "one"/"two" as assistant doesn't seem to normally parse the voice as an integer. When changing the "is" field to "one" or "two" or "three" any change instantly propagated. No issues.

I then took the liberty to modify it even further to use multiple automations in the single script:

 

metadata:
  name: Test MultiAuto
  description: Testing multiple automations in a single script.

automations:
  - name: Testing Automation 1
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Test automation one # Then replace with Test automation 2 etc.

    actions:
      - type: assistant.command.OkGoogle
        okGoogle: Tell me the weather in berlin
        devices: Living Room - Living Room

  - name: Testing Automation 2
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Test automation two # Then replace with Test automation 2 etc.

    actions:
      - type: assistant.command.OkGoogle
        okGoogle: Tell me the weather in london
        devices: Living Room - Living Room

 

This didn't work. I don't think something is wrong with how I'm using multiple automations (syntax), but please let me know?

I found that the assistant sometimes caches the single automation script. So Testing Automation 2 works, but Testing Automation 1 didn't. Eventually they both stopped working.

Very interesting. Thanks for sharing your observations @Alphabet. I am taking a note of this for internal investigations. 

Any update on this topic by any chance ? 

i guess not

Hello ? 

Its been 2 months now , do you have an update ? 

Stef-15
Community Member

Hi

I have the exact same problem.  My code follows (will be extended to all days of the week):

metadata:
  name: Garbage Assistant
  description: Scripted automation

automations:
  - starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Test garbage Monday

    actions:
      - type: assistant.command.Broadcast
        message: On Monday you should take out the white organic bag.

  - starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Test Garbage Tuesday

    actions:
      - type: assistant.command.Broadcast
        message: On Tuesday you should take out the black mixed waste bag.

 

jwl_
Community Member

Just wanted to add that I'm having the exact same issue with the 'OKGoogle' starter when there are multiple automations in one script.

@Prafulla, any updates on this issue?

Here's an example script that's not working for me.  However, when I remove either one of the automations from this script, then the remaining one works on it's own.

 

metadata:
  name: Turn on/off the great room lights
  description: When someone tells Assistant "Turn on/off the great room lights", turn on or off all the lights in the great room

automations:
  - starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Turn on the great room lights
    actions:
      type: device.command.OnOff
      on: true
      devices:
        - Dinning Room
        - Kitchen
        - Living Room

  - starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Turn off the great room lights
    actions:
      type: device.command.OnOff
      on: false
      devices:
        - Dinning Room
        - Kitchen
        - Living Room

 

jcsosia
Community Member

Same issue here with exact same formatting

Bethany07
Community Member

I'm having the same issues. I have a complex routine that won't work anymore because it has 46 actions. I've been trying to turn it into script, because I rely heavily on it. My "ok google" and any broadcast command will not work. It seems to just skip over those actions completely. The lights I have scheduled mostly work, but the other commands will not fire. 

jcsosia
Community Member

Here's an example of a multi-"OkGoogle" automation that doesn't seem to respond to each trigger. It's supposed to house all of my possible control functions for the blinds in my living room. Scenes are setup in Switchbot, and those scenes are visible and executable from Google Home. Before Script Editor (SE), I had separate automations for each of these, but I thought with SE I could bundle them up into one. Am I misunderstanding the functionality of SE and it's capabilities?

 

 

metadata:
  name: Blinds Control
  description: All controls for the blinds

automations:

  # Close them
  - starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: close the blinds

    actions:
      - type: device.command.ActivateScene
        activate: true
        devices: Night Blinds

    # Open them
  - starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: open the blinds

    actions:
      - type: device.command.ActivateScene
        activate: true
        devices: Open Blinds

    # Dim them
    # Close them halfway
  - starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: dim the blinds

    actions:
      - type: device.command.ActivateScene
        activate: true
        devices: Dim Blinds

 

 

NestJoke
Community Member

It looks like it is not only this command : assistant.command.OkGoogle
I experience the same issue with all the commands using the assistant : 

assistant.command.Broadcast
assistant.command.OkGoogle
assistant.event.OkGoogle
 

I just wanted to add that when I try to use assistant.command.OkGoogle as a starter to kick off a basic automation (I simply want to say "I am in bed"  have it read back basic information conditional on stuff like the time, just to get familiar with building the script where I will build on this later) and the script editor will not recognize the command and won't validate. 

In the end, I need to prompt Google Home to start the automation, and want to do so via voice, and not have to use my device to start it.  But I'm lost as to how to get the automation to start.

So weird! Maybe try this as the starter type: 

assistant.event.OkGoogle

 Using "event" instead of "command" may help? I also know that Script Editor is very picky about indents

martin_macikk
Community Member

I've got same problem...

(Google assistant can run only first script...)

Any updates?

I haven't tested recently. But unfortunately I don't believe so. This is probably a large internal undertaking and this is preview. They did just release a significant update to the scripting preview, but this issue doesn't seem to be included as a fix. Maybe we will see an update around October 4th. 🤞

Same problem here too. I created the simplest of automations, no other starters and very simple commands, and confirmed that only the first instance of the okGoogle starter will work.

Hollen_ar_mor
Community Member

I have the same problem :

- assistant.event.OkGoogle

- assistant.command.OkGoogle

- assistant.command.Broadcast

 

... don't work il you have a multiple conditions script needing "-name: ... ".

 

All other command or event work fine in that case.

 

We have to wait october the 4th ??

 

adamspir
Community Member

Same problem here as well. I wanted to use a single google assistant phrase to trigger different sets of lights based on time of day but this issue prevents me from achieving that 😕

jfisher51
Community Member

All - I've had the same problems with multiple starters in the same automation. My only solution was to break them up into two different automations. Not ideal, but after I did that they worked flawlessly.

NestJoke
Community Member

looks like it is fixed now,  some script i made long ago started broadcasting properly ! 😎

Stef-15
Community Member

Yes seems like it. Just tried my broken routines and they're working! Hooray! 👏👏

jwl_
Community Member

Same here!  Finally!!  🎉

Hollen_ar_mor
Community Member

Not here... (I'm in France)

Even worse : it looks like "okgoogle" starter can't work with a "broadcast" action.

This script raise up the volume, but my hub never says "lunch is ready". 

But if I start the routine manually in Google Home, it works :

 

metadata:
  name: test
  description: Scripted automation

automations:
  starters:
    - type: assistant.event.OkGoogle
      eventData: query
      is: test lumière

  actions:
    - type: device.command.SetVolume
      volumeLevel: 80
      devices: Cuisine - Cuisine

    - type: time.delay
      for: 2sec

    - type: assistant.command.Broadcast
      message: "lunch is ready"
      devices: Cuisine - Cuisine