[Deprecated, Unsupprted] Google Home Assistant Relay Driver (v1 and v2)- text to speech on Google Home devices

4/14/2019 - Added support for Swedish characters. Thanks @chrbratt!

12/18/2018 Update - Added support for the assistant-relay 'presets' using the new [P] prefix

12/16/2018 Update - Added new Assistant Relay Version 2 Driver for those users who would prefer to use Greg Hesp's new Assistant Relay v2.

NOTE: You must use the Driver that corresponds to your version of the Assistant Relay running on your Raspberry Pi (or similar.)

I recently received my first Google Home device. I was very intrigued by the Google Home Assistant Relay project over on ST.

I followed Greg Hesp's directions to get the assistant-relay nodejs server up and running on a Raspberry Pi 3. I am not going to explain those steps, as he already has them documented on his GitHub repository. Make sure you have assistant-relay working before proceeding with any Hubitat changes.

I looked at his existing Device Type Handler and SmartApp, and decided that I wanted something simpler for my Hubitat port. I know webCoRE is an option, but I wanted to stick with RM and other native apps. So, I wrote a new Hubitat Driver that implements the standard 'Speech Synthesis' and 'Notification' Capabilities, to allow it to be used by most existing Apps that look for these capabilties (like Rule Machine, Hubitat Safety Monitor, etc...)

I have posted the driver on my GitHub repository below. Simply copy (from RAW window) and paste the code into a new Hubitat Driver, then click save. Afterwards, click on Devices, Add New Virtual Device, and enter the name, label, network id, and select the 'Google Home Assistant Relay' driver from the bottom of your drivers list. Afterwards, update the user preferences with your assistant-relay server's LAN IP Address and port (defaults to 3000), click save, and then feel free to type any text you want into either of the two fields, and press the corresponding button to test it.

This driver supports most of the features of the Google Assistant Relay server.

  1. Normal TTS broadcasts are achieved by simply submitting the raw TEXT you want spoken. NOTE: A recent change by Google now results in every TTS being prefixed with "Broadcast from %username%," and then your text. This cannot be disabled as Google made this change on their back end.
    • Hello World.
    • Hubitat is amazing!
  2. Preset commands require the [P] prefix be added to you preset keyword as shown below
    • [P]wakeup
    • [P]breakfast
    • [P]lunch
    • [P]dinner
    • [P]timetoleave
    • [P]arrivedhome
    • [P]ontheway
    • [P]movietime
    • [P]tvtime
    • [P]bedtime
  3. Custom Commands simply need a [CC] prefix added to them (these are not spoken aloud, instead they cause an action as if you had spoken to the Google Assistant/Home device)
    • [CC]turn on kitchen light
    • [CC]turn off kitchen light
  4. Custom Commands with Converse need a [CCC] prefix added to them (these commands allow the Google Home device to respond aloud to your command.)
    • [CCC]what is the temperature outside

Note - feature #4 above does not always result in the same response as asking the Google Home device directly. Often it is an abbreviated response. This is an issue with Google's back end, not the Hubitat Driver, nor the Assistant-Relay NodeJS server.

Here is the driver. As always, feedback is welcome!

Assistant Relay Version 1 Driver

My personal MS Word instructions are available at Hubitat/Drivers/google-home-assistant-relay.src/RaspberryPi-Assistant-Relay_v1.docx at master · ogiewon/Hubitat · GitHub

Assistant Relay Version 2 Driver

My personal MS Word instructions are available at Hubitat/Drivers/google-home-assistant-relay-v2.src/RaspberryPi-Assistant-Relay_v2.docx at master · ogiewon/Hubitat · GitHub

Credit for 99% of this work goes to Greg Hesp over on ST! My driver is really very simple. It just issues HTTP Post commands.

[UPDATE] @Ryan780 on ST has found the fix to the problem of assistant-relay seeming to work yet no audio coming from the Google Home Device. Looks like IPv6 was the problem. Disabling it on his router resolved the issue. See below.

15 Likes

Got this up and running quite easily running the "relay" on my ubuntu server. Thanks for this driver, Google Homes are now even more useful than before!

1 Like

This new way to push speech to Google home works very well with webCoRE. This way is much easier to remember HOW to do it! lol Thanks

For those interested, here are two ways to make Google home speak once the Home Assistant is installed using webCoRE.

1 Like

Almost forgot...you can have random text too! Great for keeping everyone on their toes.

After choosing 'Speak' change the 'Message' field to 'Expression' and add in the '{Random...' stuff.

Sorry, This isn't clear to me. I need a "OAuth2 JSON file from Google" and I'm getting that how?
As I start to walk through the Google Developer Project and account settings, they're asking questions that I don't see explained in Greg's repo.

I'm lost.

Try following Ryan's instructions in his WiKi. They are much more detailed.

Also, new users seem to be having issue with the latest version of 'node' and have had to revert back to 'LTS'. My Pi was already up and running and so I didn't experience any issues. Look near the bottom of the ST thread.

1 Like

Very cool!

These instructions helped immensely

Thank you!
Getting that HE issue where it announces twice, but I'm announcing the washer or dryer has finished, so I don't mind a double notification. Is there any way to disable the tone before the voice notification? Also, how do I use "Device Notification" in HE?

I have never, ever had that happen using assistant-relay. You may have something in your Hubitat hub misconfigured.

I'll take a look. Meantime, I broke Homebridge trying to get assistant relay running :slightly_frowning_face: Need to figure that one out now.

Not that I know of.

So, within Rule Machine, for example, one of your actions can be to send a Notification. You can also click on Speak as well. Only do one of these two, or else you'll get them both. Maybe that's what you did?

Found what I did. I had previously selected "On this speech device", and it should only be "Send notification to device". Is that what you were describing?

If anyone is running an older version of node.js like I was, this instruction helped me get the right version for the Google Assistant Relay node module (8.11.3)

And when I broke homebridge, this instruction helped me fix it.

$ sudo npm -g uninstall homebridge
$ sudo npm -g install homebridge@0.4.39 --unsafe-perm

NOTE: It was not necessary to reinstall any Homebridge, but the one thing I did need to due was fix a port conflict in the config.js file for Homebridge. The Google Assistant Relay node module uses port 3000 by default, and I am running the Insteonlocal plug-in which was also using the same port, Be sure to change the Google Assistant Relay port via the node configBuilder.js script (option 2 in the script).

[Edit] `Restored my Homebridge and successfully installed Google Assistant Relay. Both seem to now be running fine together with node 6.10.2
I also changed the Google Assistant Relay port to 4000 this time, instead of changing the Insteonlocal plug-in port number.

1 Like

Yes, exactly. You can use either the Notification functionality OR the Speak functionality, but not both at the same time to the same device.

With the device driver, they both do the exact same thing.

1 Like

Anyway to set the default volume? If the Google Home device is turned down, I would love a way to have notifications always be at a specific volume.

Not that I know of. The ST thread has loads of information that may be helpful.

Thanks. Could only find that it IS possible. Posted a request for more info as to how.

You would probably need to use the custom-commands capability of assistant-relay. I did not build in support for that in my driver. But it could easily be added.

1 Like

@ogiewon Would it be possible to tweak this driver to be able to use the custom commands function of the "assistant-relay". My goal would be able to send a command to arm my Nest Secure system "home and guarding" when my hubitat enters "sleep" mode and arm "away and guarding" when it enters "away" mode.

According to the documentation for assistant-relay this is possible using the following syntax:

http://<ip_address>:<port>/custom?command=<custom command>&user=<config file user name>

I'm assuming we could use a custom command in RM to define the actiion but I'm not sure if it would require anything additional to send it as a "POST" command to the relay?

I was thinking about this yesterday. I think the simplest method would be to add a prefix to the string that is sent to the driver. If the prefix exists, it will be stripped off and the call will be made to

http://<ip_address>:<port>/custom?command=<custom command>&user=<config file user name>

instead of the normal custom broadcast call.

So, something like "[CC]set volume to 5" would not be spoken like a broadcast, but instead would perform the same action as if you were talking to the Google Home device.

Sound good? This way, no custom commands are necessary in RM.

1 Like

That sounds like it would work. The command I'd like to send for the nest secure is:

"Set Nest Secure to Home and Guarding" or "Set Nest Secure to Away and Guarding". These work using Google Assistant directly, so according to what I'm reading the "assistant-relay" thread at ST Forum it should work.