Noob trying to setup Google Home/Google Assistant - Auth code for Actions SDK project?

A few questions:

  1. How do I match the exact wording of the phrase that I use with Google Assistant to the switch? For example, if I want a switch to change the input on my receiver to “CD”, how would I define the appropriate trigger phrase and ensure that it matches the relevant command in the Broadlink switch definition?
  2. Can I use the Automation editor in the HA web interface to configure these triggers/actions? (I don’t see a trigger type which seems appropriate for Google Assistant)
  3. How can I script a series of actions to be triggered by a single Google Assistant command?
  1. You just call the name of the switch you’ve defined. If your switch is called “CD”, you just say “Hey google, turn on CD”.
  2. I don’t think you can write automations that do this.
  3. You can write a script that performs multiple actions, then expose that script to GA, then say “Hey google, activate [or start] [script name]. It sounds like most of what you want to do is achievable via scripts.

Ah OK, so my GA commands must say either “Turn On x” or “Activate/Start x”. Is that the full extent of GA’s lexicon for HA, or is there a guide somewhere which provides a full list of available phrases?

Well there is also “Turn off”, and you can also query a climate platform for states and set heat/cool modes and temp.

I’m trying to work out how to expose my Broadlink to Google Assistant, but can’t work out where the syntax from the above example fits. I currently have this at the end of my config file:
switch:

  • platform: broadlink
    host: 192.168.1.87
    mac: ‘34:EA:34:C7:87:FA’

Where do I add the google_assistant = true entry?

So I tried the syntax below, called the request_sync service (which didn’t give any feedback, positive or negative or positive, when I called it), then tried “Hey Google, turn on Samsung TV”. Google wasn’t able to help. Any advice re. what’s wrong with my config? The agent_user_id that I used was a made-up text string - I’m not sure if it is supposed to correspond to some id in the Googleverse?

switch:
  - platform: broadlink
    host: 192.168.1.87
    mac: '34:EA:34:C7:87:FA'
    google_assistant: true
    switches:
        tv_samsung:
            friendly_name: "Samsung TV"
            command_on:
            'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
            command_off:
            'JgBGAJaSFjUXNRY1FhETExYRExMWERU2FDcUNxQTFhETExYRExMWERMTFhEUNxQ3FBMVEhM3FTcXNRY1FhETExY1FzUWERMADQUAAA=='
            tv_hdmi1:
            ''
            tv_hdmi2:
            ''
            tv_hdmi3:
            ''
            
   
google_assistant:
  project_id: homeassistant-8734a
  client_id: 216010837999-kjc1pm5lgobfuscated3rgh7at3o.apps.googleusercontent.com
  access_token: xHe4Sobfuscatedor9b0JXg
  agent_user_id: mymadeupstring
  api_key: AIzaSyCFobfuscated8YdJckU-o4kNCV1AO9arT8
  exposed_domains:
    - switch
    - light
    - group
    - media_player
    - script
    - climate
    - cover

So I just realised that HA was failing to start, and had flagged a syntax error in my command_on definition. I based my syntax on the example here, but I guess I got something wrong???

switch:
  - platform: broadlink
    host: 192.168.1.87
    mac: '34:EA:34:C7:87:FA'
    google_assistant: true
    switches:
        tv_samsung:
            friendly_name: "Samsung TV"
            command_on:
            'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
            command_off:
            'JgBGAJaSFjUXNRY1FhETExYRExMWERU2FDcUNxQTFhETExYRExMWERMTFhEUNxQ3FBMVEhM3FTcXNRY1FhETExY1FzUWERMADQUAAA=='

It’s saying “Could not find expected :” for the lines containing the command_on items

OK I found out that the IR code and the “command_on:” need to be on the same line - I have managed to execute my first command from Google Home!
So the inevitable next question: much of what I want to do involves several actions, so I guess I need to define scripts in scipts.yaml. My question is: how do I define triggers for Google Assistant? Does anyone have an example of a script which is triggered by GA?

Just make sure the script is exposed to Google Assistant and then shows up in the list of home control items in the Home app. Then to run the script from GH say 'hey google, turn on . If saying ‘turn on’ is annoying you can add a shortcut inside the Home app.

Thanks for the tip, At the moment I am struggling with how to define the trigger for my script. Is it simply the case that saying “Hey Google turn on {script name]” will cause the script with that name to be executed, and that I don’t need to explicitly define a trigger in my script?

I think for scripts or scenes you have to use “start” or “activate” to invoke them (eg “Hey google, activate watch tv”, where “watch tv” is the name of the script in HA).

Yes.
If it’s not working, check the script is showing up in the Home app’s list of Home Control devices.

BTW scripts don’t have ‘triggers’. Automations have triggers. You don’t need an automation to have GH run a script.

I’ve made my first attempt at getting Google Home to execute a script, but the syntax that I’m using to expose my script to GA is being flagged as invalid.
My scripts.yaml file is below. If I remove the “google_assistant: true” line it validates fine, but it’s invalid if I include that line.
Can anyone advise on what my syntax should be?

  watch_humax:
    alias: Watch Humax
    google_assistant: true
    sequence:
      - alias: TV On
        service: tv_samsung.turn_on
      - delay:
          # supports seconds, milliseconds, minutes, hours
          seconds: 4
      - alias: Receiver on
        service: tv_samsung.turn_off

First: you need to include google_assistant: true in customize.yaml:

script.watch_humax:
  google_assistant: true

I assume tv_samsung is the name of a Broadlink switch, in which case you need to call the switch.turn_on service. This should work:

watch_humax:
  alias: Watch Humax
  sequence:
    - service: switch.turn_on
      data:
        entity_id: switch.tv_samsung
    - delay:
        seconds: 4
    - service: switch.turn_on
      data:
        entity_id: [your receiver entity id here]

Hmmm this syntax is also showing as invalid:

  watch_humax:
    alias: Watch Humax
    sequence:
      - service: switch.turn_on
        data:
            entity_id: switch.tv_samsung
      - delay:
          seconds: 4
      - service: switch.turn_on
        data:
        entity_id: switch.receiver_onkyo

I just added receiver_onkyo as a Broadlink switch, but didn’t restart the HA server. Could that be the problem?

…and this is how my broadlink switches are defined in configuration.yaml:

switch:
  - platform: broadlink
    host: 192.168.1.87
    mac: '34:XX:34:C7:87:CC'
    google_assistant: true
    switches:
        tv_samsung:
            friendly_name: "Samsung TV"
            command_on: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
            command_off: 'JgBGAJaSFjUXNRY1FhETExYRExMWERU2FDcUNxQTFhETExYRExMWERMTFhEUNxQ3FBMVEhM3FTcXNRY1FhETExY1FzUWERMADQUAAA=='
        receiver_onkyo:
            friendly_name: "Onkyo Receiver"
            command_on: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
            command_off: 'JgBGAJaSFjUXNRY1FhETExYRExMWERU2FDcUNxQTFhETExYRExMWERMTFhEUNxQ3FBMVEhM3FTcXNRY1FhETExY1FzUWERMADQUAAA=='

You’ve got some extra spaces on the first entity_id entry, and not enough on the second, try this instead:

  watch_humax:
    alias: Watch Humax
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.tv_samsung
      - delay:
          seconds: 4
      - service: switch.turn_on
        data:
          entity_id: switch.receiver_onkyo

And also too many spaces in your switch definitions, and as I said you need to move google_assistant: true to customize, try this instead:

switch:
  - platform: broadlink
    host: 192.168.1.87
    mac: '34:XX:34:C7:87:CC'
    switches:
      tv_samsung:
        friendly_name: "Samsung TV"
        command_on: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
        command_off: 'JgBGAJaSFjUXNRY1FhETExYRExMWERU2FDcUNxQTFhETExYRExMWERMTFhEUNxQ3FBMVEhM3FTcXNRY1FhETExY1FzUWERMADQUAAA=='
      receiver_onkyo:
        friendly_name: "Onkyo Receiver"
        command_on: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
        command_off: 'JgBGAJaSFjUXNRY1F...

(The second command off got cut off when I cut and pasted but obviously use the whole code).

Yaml is very sensitive to spacing issues.

When you add something to a config file, generally you have to restart HA for changes to take effect.

Thanks. I’ve stared and stared at that first entity_id definition and I can’t see where the extra space is! There was definitely only a single space after the colon after entity_id, so I guess the extra space was somewhere else? In any case, I copied and pasted your code and now it passes the validation checks - thanks.

So I can now see the script on the home page of my HA web interface, but when I click on the switch to turn it on the Broadlink doesn’t respond (I corrected the MAC address, which was incorrect in my last post). The switch moves to the right toggle position, a message pops up saying “Turned on Watch Humax”, then the switch moves back to the left position. Is the clickable toggle switch next to a script item on the home page intended to execute the script, or simply to enable it?
The Broadlink is definitely online, as it it continuing to respond to requests from IFTT via the RM Bridge app which I have running on an Android tablet. How can I check whether HA is connected to the Broadlink?

This is the switch definition for the Broadlink in my configuration.yaml:

switch:
  - platform: broadlink
    host: 192.168.1.87
    mac: '34:EA:34:C7:87:FA'
    switches:
      tv_samsung:
        friendly_name: "Samsung TV"
        command_on: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
        command_off: 'JgBGAJaSFjUXNRY1FhETExYRExMWERU2FDcUNxQTFhETExYRExMWERMTFhEUNxQ3FBMVEhM3FTcXNRY1FhETExY1FzUWERMADQUAAA=='
      receiver_onkyo:
        friendly_name: "Onkyo Receiver"
        command_on: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='
        command_off: 'JgDSAJaSFjUWNRc1FhETExYRFREWERU2FTYUNxQTFhETExYRExMWNRcQExMWNRc1FhAWERY1FhAXNBc1FhEVERY1FjUXEBUABjeTlRY1FTcTNxQTFhETExYRExMWNRc1FjUWEBYRFhAUExYREzgWEBcQFDcWNRYRFhAWNRcQFjYVNhMTFhETOBQ3FBMWAAY0lpMWNRY1FzQXEBQSFxETExYQFDgTNxc1FhAXEBYRFhAWERY1FhAWERY1FjUVEhYRFTYVERY1FzQXERMTFjUWNRcPFwANBQAAAAAAAA=='