Oh, and I sorry, I might’ve misinterpreted your question. If you were asking how to do this without using docker at all, that might be a bit more complicated.
However, it’s extremely easy to install docker on a Raspberry Pi, as there is just a single command that should set it up completely for you: curl -sSL https://get.docker.com | sh
yeah I’ve got Docker running on my server, so that’s not an issue. Was curious if I could get it integrated into my current home assistant container. Anyway to get this integrated into the official Google Assistant component?
If you have your on custom docker setup running Home Assistant in a container, then I’d say it’s best to leave it running as its own separate container.
The more compartmentalized you have your docker setup, the more manageable it is.
As to getting it integrated into the official Google Assistant add-on, I guess I could fork it and create a pull request to get a configuration variable added to the options.json to make it start in text mode instead of speaker/mic mode (but that’d require using Hass.io).
But I don’t think there is currently any way to run “your own” Google assistant in Home Assistant without running it separately. So, it’d currently either have to be with Hass.io or a custom docker container. The Google Assistant component merely connects to Google to provide your Google assistants with the ability to control your lights and such. I have that running on my HA setup as well.
So basically, this add-on is actually a full-fledged Google Assistant that can do everything a Google Home can do (just like the Hass.io Google Assistant add-on).
The only difference is that it uses their RPC modules to simulate typing whatever it is you want it to do, versus saying it out loud.
And then the webserver merely crafts a message like “Broadcast [YOUR MESSAGE]”, and it would be like telling your Google Home out loud the same thing.
Actually, come to think of it, there is a lot to be expanded upon here.
For instance, this is a full-fledged Google Assistant, yet the webhook only crafts a message like “broadcast [MESSAGE]” for now.
There could be more webhooks to expose other text-based commands you’d want to send to your Google Home. Like “Set an alarm for [ALARM TIME]”, or maybe even just an API endpoint that takes whatever text you give it and uses that as the entire message to Google.
Also, if you tell a Google Assistant something like “Broadcast time for dinner to the living room speaker” then it would only play on that particular Google Home. So, there could be way more options, but this suits my needs for now.
If others wanted to PR my repo, it could get built out to be pretty fully-functional.
Have setup as coded for now and all working thanks. Will play around with this when I have time. A really simple change to make this more flexible would be to just remove the “broadcast” intro to the text request which would then allow a completely flexible google assistant request to be made.
Cool. I got this working. I published a container (Docker) using your instructions. The requirement is that the client.json needs to be added to the host folder for it to work so that the container wouldn’t include my credentials.
I would LOVE for the message to be more generic so you could use it as you stated. Something like:
“Broadcast ‘Its time for dinner’ on bedroom speaker” or “Set a timer for 5 minutes for stove”
Then you can simply add the component input_text.intercom_message to some group. When you type something and press enter, it will play the message and then clear it from the input box.
Thanks for the feedback! I’ll definitely add a generic webhook for simply passing through the entire message. I like to keep the broadcast_message webhook though because it makes setting up the notify component a lot easier.
I’ll let you know when I’ve added that functionality, and I’ll push up a new version.
Yeah, so it must be some kind of configuration issue with the script or automation for it. Unfortunately I typed that all out from memory, so there might be something off with it somewhere.
If it works by going to it manually, then it will definitely work if the script and automation are done correctly.
Yeah, the automation plus script I created above should do the trick.
I’ve basically made the script call the notification, and then clear the input_text component. And then the automation only triggers the script if the length is greater than zero, and the input_text component state changes.
Ahh, got it. In converting your automation to AppDaemon I had a syntax error that I wasn’t catching.
Here is an AppDaemon app to monitor input_text changes and call a notify service. Basic use is as you have yours now, in the future with added webhooks this could be used to have an intercom or control specific to each room or device.
import appdaemon.appapi as appapi
#
# App to monitor input_text input to use as an intercom to google assistant devices
#
# Forum Discussion:
# https://community.home-assistant.io/t/community-hass-io-add-on-google-assistant-webserver-broadcast-messages-without-interrupting-music/37274
#
#
# EXAMPLE appdaemon.yaml entry
###
# Intercom:
# class: intercom
# module: intercom
# entities:
# - intercom_input: input_text.intercom
# notify: googleassistant
#
#
# Arguments
###
# intercom_input: input_select entity to be monitored
# notify: the notify component to use
#
#
# NOTES:
# Example Notify:
# - name: googleassistant
# platform: rest
# resource: http://192.168.1.188:5000/broadcast_message
#
#
# Release Notes
#
# Version 1.0:
# Initial Version
#
#
# ####################################################################
# ####################################################################
class intercom(appapi.AppDaemon):
def initialize(self):
if "entities" in self.args:
for item in self.args["entities"]:
intercom_input = item["intercom_input"]
notify = item["notify"]
msg = "Intercom setup using {}.".format(
self.friendly_name(intercom_input))
self.log(msg, "INFO")
# Setup Listener
self.listen_state(self.state_changed, entity=intercom_input, notify=notify)
else:
msg = "Intercom enabled but no entities configured."
self.log(msg, "INFO")
def state_changed(self, entity, attribute, old, new, kwargs):
intercom_input = entity
notify = kwargs['notify']
if new != "" and new != " " and old != new:
notifyservice = 'notify/{}'.format(notify)
self.call_service(notifyservice, message=new)
self.call_service('input_text/set_value', value=" ", entity_id=intercom_input)