Coder Social home page Coder Social logo

flecmart / google-assistant-broadcast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ismarslomic/google-assistant-broadcast

0.0 0.0 0.0 84 KB

Broadcast message to your speakers with Google Assistant without interrupting your music

JavaScript 83.84% Dockerfile 16.16%

google-assistant-broadcast's Introduction

google-assistant-broadcast

Docker Image CI

Run tiny web server which expose REST Api for sending broadcast text messages to your Google Assistant, by using the Google Assistant Service.

Get support

Bugs and questions related to the source code and Docker image can be reported at Github Issues in the ismarslomic/google-assistant-broadcast repo.

About

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:

Note

  1. You don't need to prefix the message with broadcast, shout and tell etc. as this is already done for you.

  2. According to Google Assistant doc you can broadcast to all speakers or specific speakers. I have just tested to all.

Setup

Prerequisites

  • 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

Alt 1: Run docker container with docker-compose

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

Alt 2: Run docker container with docker run

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

Using

Integrating with Home Assistant

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

Using in Home Assistant

Broadcast the message by calling the Notification service ga_broadcast (from previous step):

service: notify.ga_broadcast
data:
  message: Hello world!!

Calling the REST Api directly

Endpoint: POST http://localhost:8085/broadcast

Request payload:

{
  "message": "Hello world!!"
}

Example with curl

curl -X POST http://localhost:8085/broadcast \
 -d '{"message":"Hello world!!"}' \
 -H "Content-Type: application/json"

Known issues

1. Broadcast request gets send, but not played/broadcast to the speakers

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>

google-assistant-broadcast's People

Contributors

ismarslomic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.