[Release] Google Home Assistant Relay Driver - text to speech on Google Home devices

community_driver

#1

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.

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

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.


TTS to a Echo dot or Google mini
Google home support
Lutron Pico Audio for Echo Speakers
[UPDATED] - Message Central - Make your home speak
Control unsupported device with HE and Google Assistant
Help on automating vertical blinds
Sonoff Fan Controller - $12
Integrated alarm recommendations
Insteon integration
Google home support
Driver for "POST" requests to google assistant relay
Hubitat, IFTTT, Google Home/Assistant How To?
Leviton WiFi device support?
"App Store" for Hubitat
Phillips Hue Dimmer Switch Integration?
Mysmartblinds
Google home support
ST to HE migration plan questions
How do you use TTS?
Replacing light with fan
Nest Integration
Lutron Pico Audio for Echo Speakers
Porting VLCthing
TTS Speaker to get started
Voices
Leviton WiFi device support?
Amazon Echo Dot or Google Home Mini with Hubitat?
#2

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!


#3

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.


#4

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.


#5

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.


#6

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.


#7

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?


#8

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


#9

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.


#10

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?


#11

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?


#12

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.


#13

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.


#14

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.


#15

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


#16

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


#17

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.


#18

@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?


#19

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.


#20

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.