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

This solves the broadcasting issue, but couldn’t we also use this to send commands to google assistant?
in the code we just need to remove Broadcast and then we can fully control google… such as
we can have a button in HA send the command ‘turn on my bedroom tv’ (if you have a chromecast that has cec - which i use all the time on my 3 tv’s.
and you can run other commands to google that home assistant can’t do

Glad you fixed the issue yourself! You are right, we could generalize this solution to also handle general Google Conversation and commands, but that was not mine initial intention or need. I wanted to replace the tts integration, which interrupted the music/media being played, with a broadcasting message. You are free to fork this repo and make your own modification :slight_smile:

I’m having some issues getting this add-on to work.

I’ve already have the Google Assistant add-on working using the manual installation instructions from Google Assistant - Home Assistant. Should I use the same .json-file I downloaded for this add-on?

I’ve tried to copy the previously downloaded .json-file from the /config folder to the /share folder and renamed it to “google_assistant.json” but I get this error message in the log when I start 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'

According to a previous post this means the .json-file is not correct. I’ve also tried to generate a new .json service account key in the Google Cloud Platform but this doesn’t seem to work either. Where should the .json key be placed? Can it be a copy of the .json key I’ve already generated?

Sorry for all the questions, I would really like to get this to work for my TTS-notifications.

EDIT: Got it to work somehow using a new, generated key. However, I have two additional questions:

  1. is it possible to remove the introduction before the TTS message? My Google Home now says “Incoming broadcast. The message is…” before the message. I’m using the http://hassio.local:5000/broadcast_message?message=[MESSAGE] URL.

  2. Is it possible to choose what devices shoudl be used for the broadcast? I’ve some devices in the childrens room I sometimes don’t want to broadcast messages to.

1 Like

I think I figured out that KeyError: ‘installed’ issue. The instructions in the readme for this repo reference old instructions for the google assistant integration. I had been providing this addon with a service account json file as I was following the current instructions but it was expecting an oauth client json file from these old instructions:
addons/README.md at e836914c698c561b489467f7d214dc2f2f3006ee · home-assistant/addons (github.com)
I used the same oauth client that I had previously set up for nest and now the addon starts up fine.

1 Like

yes its possible, but the INCOMING BROADCAST phrase is not editable.

For for example sending to tan other device do this,

change text to,
broadcast to (YOUR DEVICE NAME) this is a test 1 .2 .3

I think this is working using the command querystring (@malosaa mentions this above), just not described in the documentation.

Code at:

For example, this works for me (note that in web queries, spaced get turned into %20 - you can type in the command with just spaces and the browser changes it for you):

http://homeassistant.local:5000/command?message=Play%20Youtube%20on%20the%20bedroom%20roku
or
http://homeassistant.local:5000/command?message=Turn%20off%20the%20laundry%20room%20roku

Note for anyone trying to install this (the instructions could use some updating, I started with what @halomademeapc posted),

  1. On the GCP Credentials page, add a new OAuth credential for a Desktop Client, not a web client. You’ll know it’s the right format as the json file will have an “installed” key in it. This is different than the Google Assistant credentials file for the service account.
  2. make sure you’re putting the json file in the /homeassistant.local/share/ directory (not the config directory that other config files are in)
1 Like

Can someone tell me how to get the JSON file?
I am quite stalling

I either get this with a Oauth 2.0:

Or this error in the logs with a service account:

[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'

Any help is appreciated!

Solution: @Maxi1134 I got past that issue with this below.

Go to your developer console.
Go to OAuth consent screen.
Go to +Add users, under test users.
Add the users for the test (even the owner email address if not working without it)

Found at

Im pretty sure this will all stop working in October since this uses a deprecated oauth. I use this heavily. I hope someone updates it.

1 Like

here is an tutorial,

yes i use it to, lets hope it doesnt stop working end of the year… that would be a disaster

1 Like

Hi all!

I’ve got a problem I’ve seen on this thread a few times. I’m unable to start the authentication flow. I’ve tried accessing the following urls:

http://192.168.1.158:9326, http://192.168.1.158:5000
http://192.168.1.158:9326, httpS://192.168.1.158:5000
http://mydynamicdns:9326, http://mydynamicdns:5000
httpS://mydynamicdns, httpS://mydynamicdns:5000

I’ve also forwarded those ports & tried changing the ports to something random. Always get this error from Chrome:

This site can’t be reached
192.168.1.158 refused to connect.

I’ve tried in Firefox too. I’ve put the credentials JSON (google_assistant.json) in /share, /config and /config/share and also tried renaming it to google_assistant_2.json etc.

I’ve generated new credentials through cloud.google.com and applied them to both this plugin/files and to the standard google assistant integration. The standard google assistant integration works fine, for years now.

I’m getting the following error in the logs:

[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'

Anyone has any ideas for troubleshooting?

Thanks a lot!

Look out for an email from Google with instructions to allow you to apply for a final extension until Jan 2023.

“If necessary, you may request a one-time deprecation enforcement extension for each listed OAuth client ID until January 31, 2023. For clarity, the enforcement for the OOB flow deprecation will be enforced on February 1, 2023 with no exceptions or extensions.”

1 Like

which just delays the issue - it doesn’t fix it.

Here say have a quick fix… If now I only could figure out how to apply it… maybe there are people here who do understand?

linking to specific post about this issue

1 Like

Hello, I tried this addon. It worked at the beginning for the first 2 days, then for some reason it stopped working. If I send a broadcast I get the “ok” status back like bevore, but no speaker is recieving the broadcast. Why?
The original post is from 2017. Is there a summary guide somewhere? Maybe I’ve done something wrong in the installation.
If I understand correctly, this addon is a kind of fork of the Google Assistant SDK plugin, right?
I didn’t quite understand how the two plugins work together. Do I need to run both or just the web server.
Or is there a new and more user-friendly alternative to the addon? And due to the OAuth change, something future-proof where I don’t have to configure any Google Cloud projects and services?

One of the most important questions I have: how can I remove the speaker from my Google Home app? I have 3 of these things there now, but I don’t know how to remove them. Since nothing works anymore anyway, I deleted the project, but the speakers are still there. Every time I follow the instructions in the web interface under port 9324 and link my account, I get a new instance of this device. There is a link where you can manage the Google account links, but the project I signed up for as a tester does not appear there either. Apart from that I deleted the project 2 days ago, why does the speaker still exist then?

Thanks.

Edit, I have reinstalled the Add-On and followed the documentation. It seems to be successfull, but no broadcast will be played by my Google Nest Devices.
And since I’ve tested around with the account linking procedure, I have now 5 virtual speakers in my Google Home App, but just 1 should exist. I can not remove the other speaker.

Interestingly I don’t have a fake speaker in my Google home app. Not sure why there is a difference, other than I use Google Assistant Webserver in a Docker container

At this point there doesn’t seem to be a replacement for any of these integrations that doesn’t use OAuth and Google cloud.

I’m also trying to set this up, and getting as far as the container starting and it picks up the client.json.
But when I try to load the URL http://mylocaladdress:9324 the following gets generated in the container log and my browser gets a http 500

Has anyone got this working at the moment and can offer any advice?

AttributeError: module 'six.moves.urllib_parse' has no attribute 'unquote_to_bytes'
[04/Oct/2022:08:14:45] ENGINE AttributeError("module 'six.moves.urllib_parse' has no attribute 'unquote_to_bytes'",)
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/cheroot/server.py", line 1273, in communicate
    req.parse_request()
  File "/usr/local/lib/python3.5/dist-packages/cheroot/server.py", line 702, in parse_request
    success = self.read_request_line()
  File "/usr/local/lib/python3.5/dist-packages/cheroot/server.py", line 918, in read_request_line
    for x in QUOTED_SLASH_REGEX.split(path)
  File "/usr/local/lib/python3.5/dist-packages/cheroot/server.py", line 918, in <listcomp>
    for x in QUOTED_SLASH_REGEX.split(path)
AttributeError: module 'six.moves.urllib_parse' has no attribute 'unquote_to_bytes'

UPDATE:
I resolved the above by performing the following updates from the container console:

pip install --force-reinstall CherryPy==18.1.0
pip install --force-reinstall cheroot==6.5.4

And now I can load the URL, but getting an Access Denied from google Authentication: Invalid request
:frowning:

Looks like this will be integrated into Home Assistant 2023.1 Google Assistant SDK - Home Assistant

3 Likes