Google Assistant Webserver in a Docker container

I’m back at it again and build the whole project with the dummy soundcard etc. I can auth and the token is stored correctly, but then container crashes with the following error:

/usr/local/lib/python3.7/dist-packages/google/assistant/library/assistant.py:90: DeprecationWarning: Google Assistant Library for Python is deprecated
  warnings.warn('Google Assistant Library for Python is deprecated', DeprecationWarning)
Traceback (most recent call last):
  File "/gawebserver.py", line 182, in <module>
    main()
  File "/gawebserver.py", line 133, in main
    with Assistant(credentials, device_model_id) as assistant:
  File "/usr/local/lib/python3.7/dist-packages/google/assistant/library/assistant.py", line 106, in __init__
    credentials, self._set_credentials)
  File "/usr/local/lib/python3.7/dist-packages/google/assistant/library/auth_helpers.py", line 40, in __init__
    self._credentials.refresh(http_request)
  File "/usr/local/lib/python3.7/dist-packages/google/oauth2/credentials.py", line 198, in refresh
    self._scopes,
  File "/usr/local/lib/python3.7/dist-packages/google/oauth2/_client.py", line 248, in refresh_grant
    response_data = _token_endpoint_request(request, token_uri, body)
  File "/usr/local/lib/python3.7/dist-packages/google/oauth2/_client.py", line 124, in _token_endpoint_request
    _handle_error_response(response_body)
  File "/usr/local/lib/python3.7/dist-packages/google/oauth2/_client.py", line 60, in _handle_error_response
    raise exceptions.RefreshError(error_details, response_body)
google.auth.exceptions.RefreshError: ('invalid_scope: Some requested scopes were invalid. {invalid=[a, c, d, e, g, h, i, k, l, m, -, ., n, /, o, p, r, s, t, u, w, y, :]}', '{\n  "error": "invalid_scope",\n  "error_description": "Some requested scopes were invalid. {invalid\\u003d[a, c, d, e, g, h, i, k, l, m, -, ., n, /, o, p, r, s, t, u, w, y, :]}",\n  "error_uri": "http://code.google.com/apis/accounts/docs/OAuth2.html"\n}')

I think there was a change in how oauth handles the authentication, but I’m not sure how to fix this. Any ideas?

I have same problem and I cannot move forward :frowning: Any advice for us please? I configured the oauth screen and no success.

Hi,

I finally got almost everything to work after a full day of trials and trials.
My host is a Linux Mint 18.4 on a old 2010 macbook.
(Speaker on this host is not working yet)

I generally just followed the first post, but there was many roadblocks ahead.

I needed to use: modprobe snd-dummy.

On homeassistant, I am using Portainer addon, to manage all docker things.
I made sure to delete the container for gawebserver first to make
a trial from scratch every time.

Firstly, I ran,

docker run -d --name=gawebserver
–restart on-failure
-v /usr/share/hassio/share/gawebserver/config:/config
-v /usr/share/hassio/share/gawebserver/assistant:/root/.config/google-assistant-library/assistant
-p 9324:9324
-p 5000:5000
-e CLIENT_SECRET=client_secret.json
-e DEVICE_MODEL_ID=device_model_id
-e PROJECT_ID=project_id
-e PYTHONIOENCODING=utf-8
–device /dev/snd:/dev/snd:rwm
robwolff3/ga-webserver

then I got Chrome to access, http://192.168.111.2:9324.
Followed the tutorial to complete the authorization, and this generated,
access_token.json in the folder,
/usr/share/hassio/share/gawebserver/config, for my case.

I then noticed that this container is restarting endlessly, which exceeded the number of errors
allowed (60 times in 3hours?) in Google Cloud Platform.
The log said so, so I had to wait to have it reset by google over night.

The reason of this endless restart was audio.
The log showed,
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
[FATAL:audio_input_stream.cc(47)] Input device could not be opened: default

So I made the file for asoundrc as,

pcm.!default {
type asym
capture.pcm “mic”
playback.pcm “speaker”
}

pcm.mic {
type plug
slave {
pcm “hw:1,0”
}
}

pcm.speaker {
type plug
slave {
pcm “hw:1,0”
}
}

and copied this file from host to the docker container as,

docker cp asoundrc [container id]:/root/.asoundrc

and

docker cp asoundrc [container id]:/etc/asound.conf

I think one of them would work, but lazy to check.
Now finally the log showed that it is running, and this was the first time
I was able to login to the console of the container.
Fired,

http://192.168.111.2:5000/command?message=Play John Fleming on Nest

and resulted in a streaming from spotify to my Google nest mini device.

As it was reported up in this thread, broadcast didn’t work unless I remove,
gawebserver device from Home->Assisstant Settings->devices->gawebserver.

rkjr

Resurrecting an old post, anyone know how to improve the error handling so that when there is a network fault that causes the connection to fail, either the python process is restarted, or the container is restarted?

error:

google.auth.exceptions.TransportError: HTTPSConnectionPool(host='accounts.google.com', port=443): Max retries exceeded with url: /o/oauth2/token (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f17b2fe49b0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

(currently I restart the container when I notice voice notifications have failed - usually when my router craps out…)

so i have a tv in the loungeroom with a chromecast ultra and a nest mini in my room,
im having trouble broadcasting to the tv, if i click the tv chromecast in HA i can type a message and it plays on the tv… but intterupts currently playing… so i finally got gawebserver going and integrated all working fine.
but broadcasts only come out of the nest mini… i even read up on google assistant and tried variations of the following in the browser trying to get anything to come out of the chromecast

http://192.168.1.117:5000/command?message=“Broadcast to tv, lol”
http://192.168.1.117:5000/command?message=Broadcast to tv, lol
http://192.168.1.117:5000/command?message=“Broadcast to tv”, lol
http://192.168.1.117:5000/command?message=Broadcast to tv, “lol”
http://192.168.1.117:5000/command?message=“Broadcast to tv,” “lol”

now i thought i was onto something here, i tried all of these as depending on the combination i got variations of the broadcast announcement,
if i leave out the comma after the device name the voice on my speaker says "incoming broadcast from chris, “to tv lol”
if i leave it in as the example on Broadcast voice messages to Google Nest or Home devices - Android - Google Nest Help

A room * “Broadcast to [room name] [message].”

  • “Broadcast to the living room, it’s time to start homework.”
    A device * "Broadcast to [device name] [message].”
  • “Broadcast to kitchen display, is dinner ready yet?”

they use a comma, so i thought as per the command that was needed…
i tried just a normal broadcast… ie with no target … only works on nest mini
i tried targeting the room… no luck
all devices are on same wireless network, set up by same phone and linked to same google account
if any1 could help it would be greatly apreciated

Afaik you can only broadcast to google nest/home speakers and displays; not Chromecast devices.

I can broadcast to my chromecast with google TV

I sit corrected then - Google TV tests support for Assistant broadcast messages - 9to5Google

But that suggests it is only support on Google TV, not Chromecast devices…

not all chromecasts, just the one with googleTV baked in.

ahhh, thnx

Did you ever succeed on the synology?

I did not unfortunately.

However, I did move my HASS install to a NUC, so I can try if this works there.
Thanks for the reminder :wink:

linking to specific post about forthcoming issue

Trying to run this as a Docker container on my Asustor NAS, but after following all the steps and running the Docker compose stage, I just get this in the logs

[Info] Start WebUI for handling oauth2
[25/Aug/2022:02:25:15] ENGINE Listening for SIGTERM.
[25/Aug/2022:02:25:15] ENGINE Listening for SIGUSR1.
[25/Aug/2022:02:25:15] ENGINE Listening for SIGHUP.
[25/Aug/2022:02:25:15] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.

[25/Aug/2022:02:25:15] ENGINE Started monitor thread 'Autoreloader'.
[25/Aug/2022:02:25:15] ENGINE Serving on http://0.0.0.0:9324
[25/Aug/2022:02:25:15] ENGINE Bus STARTED

but neither 0.0.0.0:9324 nor my actual host ip address:9324 resolve. Connection times out.

Any ideas?

just checking when you say “actual host ip” you mean the IP of the NAS? As thats what you need to access…

If you do mean the NAS and it still doesn’t work, do you have any other working docker containers?

Yes, sorry, the ip address of the nas.

Yep. I’m running Home Assistant and JSZwave2MQTT and Calibre all with accessible ui interfaces. Not seeing any big difference between their configs.

If something were wrong with my Google project id or my device model id, would the ui interface still load?

My GAWebserver is working ok, so not sure if it is a good test, but I also get a timeout on :9234

If you goto http://host:5000/broadcast_message=testing what happens?

Is this project still maintained? If not, could somebody point me to an alternative? The GitHub repo says that the project has been archived https://github.com/robwolff3/google-assistant-webserver

pretty much none of them are being maintained. Thus unless someone provides a migration path or fix, they will all stop Feb 2023

in the nick of time, Google Assistant SDK - Home Assistant