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

hassio-addon
Tags: #<Tag:0x00007fd085710888>

#22

I forgot to put the notify component


#23

Awesome. :slight_smile:

So you got it to work?


#24

I can’t seem to get the UI to clear the field after submit - is that something you customized?


#25

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.


#26

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)



#27

Yes! Only thing that after a restart in the box is shown unknown (minor issue)


#28

Have you been able to get the “special” broadcasts to work using this method? For instance, if I personally say “Broadcast, it’s dinner time” - google will ring a bell and then say “it’s dinner time” or “Broadcast, I’m home” will play a trumpet followed by “Hey there, kylerw has arrived”.

When using the intercom, it always plays back using TTS/Text To Speech.


#29

I haven’t tried that out, but it could need to be specifically formatted a certain way. If you have the Google Assistant app on your phone, then it let’s you try out text messages that you can then move over to Home Assistant.

So, in the Google Assistant app, it would be “broadcast [some message]”.

Here’s the link to the specific messages in case you haven’t seen it yet:
https://support.google.com/googlehome/answer/7531913?co=GENIE.Platform%3DAndroid&hl=en


#30

Yeah, I took the liberty of adding a new api resource for a generic command and using broadcast without the quotes around the message gives the special responses.


#31

Awesome! I’m definitely going to have to add all that when I get home then.


#32

Just submitted a PR for the changes I had made. Hopefully that’s ok. :slight_smile:


#33

Struggling to set a timer with this using my edited API. If anyone works out the correct syntax (and the same goes for an alarm) without require any additional chat/response please feed back here.


#34

I think the issue is that the alarm or timer is being set on the “virtual” google home and there currently is not the capability to set a timer or alarm on another device.


#35

That would explain it. Thanks.


#36

Not seeing your pull request by the way. Interested to see it as I’d already submitted one myself but I’m no coder!


#37

Hey andrewdolphin! I have a comment or two on your PR. I’d say once those two minor things are taken care of, I can trigger the Docker build from where I am and get the new version out there.


Sending commands to Google Home
#38

Just merged a PR from @kylerw that takes the add-on to version 0.0.3, adding a webhook for generic messages that aren’t for broadcasts.

http://[HASSIO LOCAL IP]:5000/command?message=[any Google command]

You can use this to send any generic message you want to Google that the Google Assistant app could normally handle.

“Turn on the hallway lights,” or “Set a reminder for [something]”, etc.


#39

We should change to that (rather than have 2 types)?


#40

@anon35356645

It’s just a version upgrade, and Hass.io would suggest it. Although, if it’s working for you, then there’s really no need to upgrade.


#41

but if I use this, in order to broadcast a message I have to add BROADCAST in the text before the message, correct?
Basically I can:
turn on living room light
or
broadcast It’s time for dinner