HowTo: Listen & Talk to your Home

Tags: #<Tag:0x00007faed6a70120> #<Tag:0x00007faed6a71908> #<Tag:0x00007faed6a77ec0>

Difficulty Level: Easy to Medium -/- (Duration: ~2 hours) -/- version 2018111901

This is a very basic Tutorial on how to configure your openHAB2 System to enable Voice control and Text-To-Speech (TTS).

At the end of this Tutorial, you will be able to:

  • Use Voice Commands on your Phone (using Google Assistant) to control openHAB2
  • Use your Web Browser to listen to Audio Notifications from openHAB2

Table of Contents

  1. Introduction
    1.1 How does it work?

  2. Installation Guide
    2.1 openHAB Cloud service
    2.2 Google Text-To-Speech Add-On
    2.3 Google Home Mobile App
    2.4 HABPanel

  3. Advanced Setup (Audio from rules, etc)
    3.1 Google Home Timed Devices setup

  4. FAQs

1. Introduction

This guide is based on and was last tested with the following components:

Important Note: The Google TTS Add-on can also work on Raspberry Pis starting with openHAB 2.4.0 Snapshot Build # 1446.

1.1 How does it work?

How does it work?

Your openHAB2 system will create 2 connections:

  1. To myopenHAB.org Cloud Service to allow remote (voice) control using Google Assistant
  2. To Google’s Cloud to send text and receive audio

2. Installation Guide

2.1 openHAB Cloud service

Full instructions on how to to connect your OH2 instance to myopenhab.org are available on https://www.openhab.org/addons/integrations/openhabcloud/

2.1.1 Install the Add-on from PaperUI -> Misc -> openHAB Cloud Connector

2.1.2 Create an account on myopenhab.org using your UUID & Secret

2.1.3 Create a demo Item and expose it to the myopenhab Cloud

cloud_demo.items

Switch Voice_Robot "Voice Testing" ["Switchable"]

2.1.4 Place it on your sitemap, toggle it ON/OFF to get a first state and the check https://myopenhab.org/items. It should appear with a Status and a Last Update

2.1.5 Setup Step 1 is done! You have now successfully linked your local openHAB2 installation to the Cloud and can expose Items to external services.

2.2 Google Text-To-Speech Add-On

Full instructions on how to to connect your OH2 instance to Google TTS are available on https://www.openhab.org/addons/voice/googletts/

2.2.1 Install the Add-on from PaperUI -> Add-ons -> Voice -> Google Cloud Text-to-Speech

2.2.2 Perform the steps described on Obtaining Credentials and get your service account key in JSON format

2.2.3 Configure Google TTS Add-on under PaperUI -> Configuration -> Services -> Voice as follows:

2.2.4 Configure the Voice settings under PaperUI -> Configuration -> System -> Voice as follows:

2.2.5 Configure the Default Sink to be Web Audio under PaperUI -> Configuration -> System -> Audio

2.2.6 Setup Step 2 is done! Now you have linked your OH2 to Google and can use TTS. Test it using the following rule (toggle the test Switch from OFF to ON) and having PaperUI open on your browser.

voice_demo.rules

rule    "Voice Testing Rule"
	when
		Item    Voice_Robot     changed from OFF to ON  
	then
		say("Hello from openHAB!")
end

2.3 Google Home Mobile App

Full instructions on how to to connect your OH2 instance to Google Assistant are available on https://www.openhab.org/docs/ecosystem/google-assistant/

2.3.1 Install Google Home mobile app from Play Store

2.3.2 Add a “Works with Google” device -> search for openHAB -> login to myopenhab.org and allow OAuth2

i)

ii) iii)
iv) v) vi)

2.3.3 Add smart home devices -> Select the Voice Testing device and control it from Google Assistant !

2.3.4 Toggle the Voice Testing Switch from OFF to ON using Google Assistant and hear the Hello from openHAB message on your web browser (the rule will trigger) :slight_smile:

2.4 HABPanel

<add content about HABPanel>: Custom widgets, Web Audio, etc

3. Advanced Setup (Audio from rules, etc)

3.1 Google Home Timed Devices setup

<add content with complex rules examples>

4. FAQs

1. Why some of my Items do not appear on the myopenHAB.org Cloud platform?

Make sure that:
i) The Items have received at least 1 state update (manually or from their binding)

ii) The Items do not have the autoupdate option set to "false" (not "Veto an auto update" on Item settings)

2. Why do I get "Couldn't update the setting. Check your connection" every time I try to add the openHAB Smart Home Service in the setup of the Google Home App?

Make sure that:
i) Your openHAB Cloud settings are set to: "Notifications & Remote Access" (not only Notifications)
ii) The Items that you have exposed to myopenHAB.org Cloud Service are properly tagged and have labels

3. Do I need to own a Google Home Device for getting Google Home App to work?

No. You can simply use the mobile Google Home App linked to openHAB via myopenHAB.org

4, Which are the currently supported Tags with the Google Home Integration?

["Lighting"]
["Switchable"]
["Scene"]
["Outlet"]
["Thermostat"]
["CurrentTemperature"]
["CurrentHumidity"]
["TargetTemperature"]
["homekit:HeatingCoolingMode"]

5. All my stuff are defined by using PaperUI.. how do I add Tags to my Items? Use the REST API to add/remove Tags from Managed Items. See here how: Add Tags
Make sure that you have the "REST Documentation" Add-on installed (PaperUI->Add-ons->MISC)

6. I added recently a new Item with the proper tag but it doesn't show up in Google Home App

Use Google Home App and say/type: "Sync my devices"

7. Where can I find more examples of Items with tags?

Check the general Items Documentation & specific GA Items Configuration

8. How can I identify my UUID & Secret for registration to myopenhab.org?

Check the openHAB Cloud Documentation

9. How can I change the TTS Voice and Audio Sink within my rules?

Use: say("text","voice","device")

Example: say("Hello","googletts:enGBWavenetA","webaudio")

10. How can I see all available Google TTS voices?

Use the openHAB console and type: voice voices
The default one will be the one with the asterisk to its left

11. How can I get this to work with Alexa?

You cannot. This tutorial is for Google Assistant, not Alexa.

12. How can I enable DEBUG logs for this stuff?

Use the openHAB console and type:

log:set DEBUG org.openhab.io.openhabcloud

log:set DEBUG org.openhab.voice.googletts

More updates soon with much more info !

Please do not use this thread for troubleshooting purposes!
If you are having trouble setting up any of the above, please refer to the respective sections in the forum and search for existing solutions. If you cannot find one that solves your specific problem, create a new thread linking to this tutorial and adding as much info as possible about your setup!

Topic Community Section
General Help https://community.openhab.org/c/setup-configuration-and-use/beginners
myopenhab Cloud Service https://community.openhab.org/c/apps-services/my-openhab
Google Text-To-Speech Add-On https://community.openhab.org/c/add-ons/text-to-speech
HABPanel App https://community.openhab.org/c/apps-services/habpanel
22 Likes

<reserved>

Visio file for whoever wants it: https://openhab.page.link/tc4X

1 Like

Excellent tutorial @Dim, keep up the fine work and Thank You!:fireworks:

2 Likes

Fantastic tutorial! I know I’ve always found TTS to be a bit of a mystery. Thanks for posting!

2 Likes

It’s funny: I was also worried about this, but it was easy to setup. You need to be careful with Google’s Cloud Platform and to perform the steps in the docs to get the JSON. After that, it’s very smooth.

This will be improved according to my understanding, since @wborn is planning to change the API (Ref: Google TTS addon for OH2 & https://github.com/openhab/openhab2-addons/pull/4221). I didn’t use the testing jar for the tutorial since I would have pushed everyone to Snapshots to use it :wink:

1 Like

Damn fine tutorial @Dim
But, I seem to recall something about Google text to speech doesn´t work on Rpi. If thats correct, perhaps it´s worth mentioning in your guide,

2 Likes

@Dim About your FAQ Q3:
Google Assistant (and openhab) also support [ “Outlet” ] and [ “CurrentHumidity” ].

2 Likes

It’s correct. I added a note on top (intro). There is a Snapshot release of the addon that will work on rPis, but you need to run 2.4.0 Snapshot core to run it. Ref: Google TTS addon for OH2

Check (updated). The docs need update also in this case :slight_smile:

Thanx!

1 Like

Great… I really look forward to skip the Voice_RSS. I want Google both ways :grinning:

This is unfortunate yes… This page is more updated that the original is :frowning:

2 Likes

added 2 more FAQs. I think that they are useful in tutorials

1 Like

aha! the openhab documentation bot is slow again :slight_smile:
It should have pulled that version and published it on https://www.openhab.org/docs/ by now (last update to your link is 26 days ago :slight_smile:

Thanx for the link ! I will further update the supported tags

1 Like

Regarding the [“CurrentHumidty”] there is a small note to catch. It doesn´t show anywhere. It´s part of the thermostat. It confused me some days ago, when I added it to my setup. One simply have to ask for the humidity to know if it works.
Since this guide is is about listen and talk to. I´ll let you decide if it´s worth mentioning :slight_smile:

1 Like

Here’s one you might want to include on the Q&A, or at the top of the topic.

Q: How can I get this to work with Alexa?

A: This tutorial is for Google, not Alexa.

Surprised no ones asked this yet.:smile:

3 Likes

Added :wink: :smile:

2 Likes

Please read this, also located at the end of the tutorial.

Thanks

2 Likes

Hi Dim…
I have a question. (well, partly an request :slight_smile: ).
My plans is to use several devices for “listen and talk to” spred around all over our house. That include several Google home devices, as well as one android tablet, (main communication device). I have however yet to discover how to use a tablet for both talk to as well as listen…
As far as I understand you´r tutorial, you´re dealing with one device only, which is the default sink? I wonder if you could spred some light about this issue of using more than one device, if that is possible at all?

The default sink in my tutorial is Web Audio. This means: Any Web Browser pointing to either PaperUI or HABpanel URLs.

I used 2 devices: my PC and my mobile to test things out and I had PaperUI always open on the PC, so I was able to listen to the TTS audio.
If you have 2 browsers (or tabs) open to both PaperUI and HABpanel, you will listen to the same audio output twice :slight_smile:

I don’t know if you use a tablet and have the browser in the background, working with the Google Home App in the foreground, if you will be able to receive the Web Audio (most likely no :frowning: ).

The audio feedback is “channeled” only to the browser (not to the GH app)

Since you will have Google Home devices available, you can send the TTS Audio to them (either configure the default to Sink to be the GH device or specify the audio sink in your say command)

Thats smart :smile: Except, in my plans…

… is a bit tricky, cause I will not be using web audio. I will be using chromecast´s devices as “speak to”, as well as “listen to” TTS audio. And even more, I plan on making somekind of presence detection, and only send TTS audio to that/these rooms where presence is detected. I know, this will require rather advance rules. But at least thats an idea. :slight_smile:

I know how to cast TTS audio to chromecast devices. I already do that with the one Google Home Mini I´ve got. My concern is, how to cast TTS audio to an Android tablet. I dont even know if thats possible, unless I´ll be using the web audio. I guess this is a question to be searched for…

It should now work out of the box on Raspberry Pis with 2.4.0-SNAPSHOT Build #1446 or newer.

1 Like

Thanx! I am updating the first post now

Quick clarification question: Everything with regards to the installation instructions posted on: https://www.openhab.org/addons/voice/googletts/ remains the same… Correct? (get JSON, plug it in PaperUI)

1 Like