Community Hass.io Add-on: Google Assistant Webserver (broadcast messages without interrupting music)

##############  TTS
  - alias: Broadcast message
    trigger:
      platform: state
      entity_id: input_text.broadcast_message
    condition:
      condition: template
      value_template: '{{ (states.input_text.broadcast_message.state | length) > 0 }}'
    action:
      - service: script.send_broadcast
  - alias: Send Google command
    trigger:
      platform: state
      entity_id: input_text.google_command
    condition:
      condition: template
      value_template: '{{ (states.input_text.google_command.state | length) > 0 }}'
    action:
      - service: script.send_google_command
  send_broadcast:
    sequence:
      - service: notify.google_assistant
        data_template:
          message: '{{ states.input_text.broadcast_message.state }}'
      - service: input_text.set_value
        data:
          entity_id: input_text.broadcast_message
          value: ''
  send_google_command:
    sequence:
      - service: notify.google_assistant
        data_template:
          message: '{{ states.input_text.google_command.state }}'
      - service: input_text.set_value
        data:
          entity_id: input_text.google_command
          value: ''
notify:
  - name: Google Assistant
    platform: rest
    resource: http://192.168.1.238:5000/broadcast_message
  - name: Google Assistant Command
    platform: rest
    resource: http://192.168.1.238:5000/command

input_text:
  broadcast_message:
    name: Broadcast Message
  google_command:
    name: Google command

Should that be notify.google_assistant_command?

2 Likes

yes!!

have gone through the code 50 times and I didnā€™t see it. Thanks.

Now last (minor thing), when HASSIO starts in the box its written UNKNOWN which you have to cancel before typing in. Any way to remove it automatically when it starts?

With an input_text component, there is an ā€œinitialā€ config that you can use to populate it with the initial value.

Try something like:

input_text:
  broadcast_message:
    name: Broadcast Message
    initial: ''
  google_command:
    name: Google command
    initial: ''
1 Like

Somehow I recieve this message within the add-on:

[Info] Install/Update service client_secrets file
[Info] Start WebUI for handling oauth2
Traceback (most recent call last):
  File "/hassio_oauth.py", line 76, in <module>
    user_data = json.load(data)['installed']
KeyError: 'installed'

My Google Home is already configured and working but not hoped for the get this add on up and running.

1 Like

Have you included client.json per the instructions?

1 Like

@Imperial-Guard

This is due to a missing google_assistant.json file as per the docs here:

Created a new ID and itā€™s working thanks for the support !

1 Like

Is a script needed for broadcasting a message or can this be also done in a automation directly?

For example what to send a push notification I use:


  action:
    -  service: notify.ios_iphone_xx
       data:
          title: "Deurbel"
          message: "XX, er staat iemand aan de deur!"

To create a notification component for this add-on, you could do this:

notify:
  - name: Google Assistant
    platform: rest
    resource: http://[HASSIO LOCAL IP]:5000/broadcast_message

And you will then have notify.google_assistant that you could use just like your iOS example above.

A great thanks for your quick help! Another question any ideas how to raise only the broadcast volume?

No problem :slight_smile:

And yeah, Iā€™m not too sure if there is a way to only increase the broadcast volume. I believe it just uses whatever the volume you have set for the Google Home.

Thanks, Is there any way to have all broadcasts synced across all Google homes? It sounds like I have an echo because I can hear 2 google homes at the same time.

From what Iā€™ve researched, Google sends them all out at the same time, but there might be network latency issues causing some to play a split second before or after.

Thereā€™s nothing that can be done from within this add-on to help that. Google is actually the one that is sending the sound to the Google Home devices, and this add-on is simply a fake Google Home that is being told ā€œBroadcast [message].ā€

If you had three Google Homes, and you told one ā€œBroadcast this is a testā€, then youā€™d hear that same echo sound from your other two Google Homes.

Thanks, Is there a way to broadcast a sound file like mp3 stored in maybe /share directory?

1 Like

That would be a great idea! Playing doorbell sounds in the kitchen with my Google Home Mini :slight_smile:

This is an amazing add-on. Loving it so far.

Is it possible to request my google home mini to play music by requesting in the add-on? I been trying to but canā€™t figure out how to do it or if its even possible.

ā€œPlay X by Y using Google Play Music on Z Speakerā€

so you would use:

http://[HOST]:[PORT]/command?message=Play filthy by Justin Timberlake using Google Play Music on Kitchen Speaker

EDIT: this is finicky for me. I had it working but it doesnā€™t seem to want to let me repeat it.