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

I use your python script, but i did my setup in a LXC container instead, and change the language for french-canadian. It’s super! Thanks a lot. Someboday know if is it possible to just ear the message, witouth the annoucement “Message from Patrick” before the message ?

I’ve started getting the following error recently. It was working previously, but seems to have stopped. I get an Internal Server Error when I try using the URL directly. Not sure if its something in particular I did or something else. Anyone have any suggestions on what could be causing it?

ERROR:flask.app:Exception on /broadcast_message [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.5/dist-packages/flask_restful/__init__.py", line 480, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/flask/views.py", line 88, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/flask_restful/__init__.py", line 595, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/hassio_gassistant.py", line 40, in get
    response_text, response_html = assistant.assist(text_query=text_query)
  File "/hassio_gassistant.py", line 132, in assist
    text_response = resp.dialog_state_out.supplemental_display_text()
TypeError: 'str' object is not callable
INFO:werkzeug:192.168.1.1 - - [21/Dec/2018 14:23:32] "GET /broadcast_message?message=%22Testing%22 HTTP/1.1" 500 -

@AndBobsYourUncle Somehow the broadcast function is not working for me. However some of the custom commands do work. I tried calling the commands with my browser:
http://hassio.local:5000/broadcast_message?message=Hallo Test

The page says “Okay” but nothing happens. Debug shows:

INFO:werkzeug:192.168.0.11 - - [31/Dec/2018 15:14:36] "GET /broadcast_message?message=Hallo%20Test HTTP/1.1" 200 -
DEBUG:root:None

My Activity only shows this:
image

I suspect this not working because in German the command isn’t “Broadcast”. We use “Nachricht an alle ” (Message to all).

I tried using the custom command, but nothing happens either. Also, My Activity is showing the text without any response.
image

However, other custom commands are working (turn on the lights for example).

More of my log if necessary:

INFO:werkzeug:192.168.0.11 - - [31/Dec/2018 15:13:59] “GET /command?message=schalte%20das%20licht%20an HTTP/1.1” 200 -
DEBUG:root:None
INFO:werkzeug:192.168.0.11 - - [31/Dec/2018 15:14:36] “GET /broadcast_message?message=Hallo%20Test HTTP/1.1” 200 -
DEBUG:root:None
INFO:werkzeug:192.168.0.11 - - [31/Dec/2018 15:15:12] “GET /command?message=Erz%C3%A4hle%20mir%20einen%20Witz HTTP/1.1” 500 -
DEBUG:root:None
INFO:werkzeug:192.168.0.11 - - [31/Dec/2018 15:15:46] “GET /command?message=Nachricht%20an%20alle%20Test HTTP/1.1” 200 -

Does anyone have any idea how to get this to work?

Try this and see if it works

http://hassio.local:5000/command?message=broadcast hallo

Thanky for your reply. Sadly, this doesn’t work either.

The same command is working when typing it into the phones assistant, however.

Thought id add. I’ve created a Google Assistant web server container for Docker based on @chocomega edits so it works with remote casting to. You can check it out here.

1 Like

I love the idea of this add-on, but I can’t seem to get it to work. I followed the Google OAuth steps (in fact, I’ve done that several times) and download the .json client secret. However, when I start up the app and try to do the initial authentication step, I always get the error below. I even completely rebuilt my Home Assistant server from scratch and tried to get this add-on to work as one of my first steps but found the exact same error message. Anyone have thoughts on what might be causing this? Thanks in advance!


500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/cherrypy/_cprequest.py”, line 627, in respond
self._do_respond(path_info)
File “/usr/local/lib/python3.5/dist-packages/cherrypy/_cprequest.py”, line 686, in _do_respond
response.body = self.handler()
File “/usr/local/lib/python3.5/dist-packages/cherrypy/lib/encoding.py”, line 221, in call
self.body = self.oldhandler(*args, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/cherrypy/_cpdispatch.py”, line 54, in call
return self.callable(*self.args, **self.kwargs)
File “/hassio_oauth.py”, line 46, in token
self.oauth2.fetch_token(self.user_data[‘token_uri’], client_secret=self.user_data[‘client_secret’], code=token)
File “/usr/local/lib/python3.5/dist-packages/requests_oauthlib/oauth2_session.py”, line 244, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File “/usr/local/lib/python3.5/dist-packages/oauthlib/oauth2/rfc6749/clients/base.py”, line 411, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File “/usr/local/lib/python3.5/dist-packages/oauthlib/oauth2/rfc6749/parameters.py”, line 379, in parse_token_response
validate_token_parameters(params)
File “/usr/local/lib/python3.5/dist-packages/oauthlib/oauth2/rfc6749/parameters.py”, line 386, in validate_token_parameters
raise_from_error(params.get(‘error’), params)
File “/usr/local/lib/python3.5/dist-packages/oauthlib/oauth2/rfc6749/errors.py”, line 415, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Bad Request
Powered by CherryPy 17.0.0

After trying everything imaginable, I finally decided to follow this guide by Google:

That guide walked me through installing Google assistant SDK on my server, creating a project, generating credentials, etc. At the end of the guide, it generated a credentials file. I could copy the credential file over to my docker image for this add-on (copied to /data/cred.json). Finally, I could use the a.dd-on. What a headache… I still don’t understand why the add-on couldn’t handle my oauth registration.

Tried to uninstall the Addon, Reinstalling it and running the whole Auth-Instructions again witha new project.
But still, I get the same result. Working Home Automation commands, but no broadcasts.

Any help appreciated!

I love this add on and i’ve been using it to integrate devices where the there is no local control API such as bond home for my ceiling fans. Is it possible to get the actual response instead of {“status”: “OK”} so i can parse this message and create automations?

I had this working but it has since started giving me the below error whenever a broadcast is attempted… any ideas what to do?

Error sending message. Response 500: INTERNAL SERVER ERROR:

NoneType: None

I tried stopping the add-on and restarting, didn’t help

Can this component handle multiple language?

I have my Google home in English and Italian. I wish to broadcast in English, but it speaks the broadcast message using the Italian accent, which is bad

1 Like

Is there any update on the : Broadcasting From : PRoblem?

It is done in the backend by google. Unless they give an option via the api it cannot be removed at this time.

Thanks man! I recalled myself Hal on Google.

Now let’s get the roomate to freakout when 7 Googles minis have Hal announcing stuff!

Hey @AndBobsYourUncle i have a quirky situation

when i call http://hassio.local:5000/command?message=turn on all lights it works flawlessly owever if i call
http://hassio.local:5000/broadcast_message?message=resume spotify i get a 500 error. Any Idea why this is the case?

2 Likes

Im trying to create a couple automations around the message command, has anyone tried sending a command that asks for a pin, set a delay and respond?

I can start my car with google and Id like to create a couple scripts for opening the garage starting the car and handing the lights, thermostat, etc…

I have a routine that works perfect everytime just saying ‘start the q60’, Infiniti comes back and asks for a pin. I say the pin, it startsd. Ive tried setting delays and a few other things but no luck yet. But I do see the commands making it to infiniti, I see the ‘remote engine start failed’ mentions in my history.

I thought I was finally going to be able to get this to work, Ive wanted this automation forever. Please help if you have some ideas, thanks!

Is it possible to get the predefined messages (dinner time, movie time, I’m home etc) to work as well?

I’m wondering the same thing, have you found a solution @sunglass_guy?

My use case: Because Nest Secure can only be turned on with Google Assistant, I’m using this add-on to turn on the alarm via HA by sending commands like Set Nest Secure to Away and Guarding. It works, which is awesome, but I have no way of confirming that it works. What I’d like to do is use this add-on to ask Google What’s the status of my security? and then parse the response to determine if it’s actually on or not.

If that’s not possible, I’m curious if anyone has any other suggestions? E.g. is it possible to send these commands and actually hear the Google Assistant’s response through one of my Google Home Minis? Another option is to check the Nest home_away state (because it gets set to away after the alarm is on), but that doesn’t happen unless you’re leaving the house and the countdown to actually turn on the alarm has finished.

As an aside: Not sure why Nest is making this so hard. I get why they wouldn’t want to expose an API to disarm the system, but what’s the risk in letting third-party applications turn the alarm on?

Can you arm Nest Secure with a Routine in the Google Home app? If so, you could run Android-x86 in a VM and use Tasker/Autoinput to get the Home app in the VM to run the routine on a specific Assistant speaker, in which case the response is spoken through that speaker. I do something similar to turn off the Home Hub displays in my master suite at night, because the only way to do so is with a routine running on that device (You can’t just say “turn off display on XXX”, for whatever reason).