Run tiny web server which expose REST Api for sending broadcast text messages to your Google Assistant, by using the Google Assistant Service.
====== IMPORTANT - REPLACED by GOOGLE ASSISTANT SDK in HA! ======
Home Assistant finally provides Google Assistant SDK integration from v2023.1.0
. It supports broadcasting message without interrupting music/video playback and also sending text commands. This is exactly what you will get with setting up the google-assistant-broadcast
docker container. Since this covers my needs, and is easier to setup, I will not continue maintaining this repo. You are free to continue/start using it, or forking it to continue improvements.
====== IMPORTANT! ======
Bugs and questions related to the source code and Docker image can be reported at Github Issues in the ismarslomic/google-assistant-broadcast repo.
Ever wanted to broadcast a voice message to your Google Assistant enabled speakers in your home, without interrupting your music that is currently playing? Now you can, and I have tried to make it quit easy for you.
I have made this after a lot of research, and it all started with this thread on the Home Assistant forum.
I want to give credits to:
- endoplasmic/google-assistant by @endoplasmic
- AndBobsYourUncle/google-assistant-webserver by @AndBobsYourUncle
- greghesp/assistant-relay by @greghesp
-
By default, you don't need to prefix the message with
broadcast
,shout
andtell
etc. as this is already done for you. The message will be broadcast to all speakers connected to your Google account. -
According to Google Assistant doc you can broadcast to specific speakers as well, with the message
Broadcast to <name of the speaker's room>, Hello world.
You can also send commands to Google Assistant, such as Turn off lights in living room
, by disabling default message
prefix (with "broadcast"
).
Add environment variable APPEND_BROADCAST_TO_MESSAGE=false
in your docker run
command
or docker-compose
file and send the POST
request
{
"message": "Turn off lights in living room"
}
- docker - you need to have Docker installed on your machine, read Get Docker for more information.
- Google OAuth 2.0 Client ID and Access Keys - in order to authenticate yourself and get access to your Google
Assistant
- You can find help and more information at ismarslomic/google-assistant-oauth
Create a sub folder, ie /home/pi/config
, and add files client_secret.json
and tokens.json
.
docker-compose.yml
version: '3.8'
services:
google-assistant-broadcast:
container_name: google-assistant-broadcast
image: ismarslomic/google-assistant-broadcast:latest
restart: unless-stopped
ports:
- "8085:8085"
volumes:
- /home/pi/config:/usr/src/config
docker-compose up -d
Create a sub folder, ie /home/pi/config
, and add files client_secret.json
and tokens.json
.
docker run -d --name google-assistant-broadcast \
-p 8085:8085 \
-v /home/pi/config:/usr/src/config \
--restart unless-stopped \
ismarslomic/google-assistant-broadcast:latest
You can easily integrate this REST Api in Home Assistant by using the RESTful Notifications platform.
Add following to your configuration.yaml
file:
# Google Assistant Broadcast - REST Api
notify:
- platform: rest
name: ga_broadcast
resource: http://localhost:8085/broadcast
method: POST_JSON
Broadcast the message by calling the Notification service ga_broadcast
(from previous step):
service: notify.ga_broadcast
data:
message: Hello world!!
Endpoint: POST http://localhost:8085/broadcast
Request payload:
{
"message": "Hello world!!"
}
curl -X POST http://localhost:8085/broadcast \
-d '{"message":"Hello world!!"}' \
-H "Content-Type: application/json"
I was able to get the container up & running, but when I send broadcast request via Postman/CURL/Home Asisstant no message is played on my speakers and I get the following lines in the logs (more details about this issue at #5):
Sending message: Broadcast Hello world!
[OK] Conversation Response: empty
[OK] Conversation Completed
Possible solution 1
Delete existing device registration at Google Actions Console and re-create it, more details in comment on #5
Possible solution 2
This issue is related to the language settings we set in the container, when using the
Google Assistant SDK (default is en-GB
). It's hard to say exactly what the issue is, but for me
it helped to switch from en-US
to en-GB
. It might also be necessary to play with the language
settings in the Google Assistant app for the same Google account.
You can try changing the language settings by setting the environment variable LANGUAGE
to one of the
supported languages codes.
Add -e LANGUAGE=<language_code>
option if running with docker run
command or environment
if you
use docker-compose
:
version: '3.8'
services:
google-assistant-broadcast:
...
environment:
- LANGUAGE=<language_code>