This setup will allow you to issue individual button press commands by voice from a Google Home device to multiple Harmony hubs. Example uses:
“Hey Google, tell living room to pause”
“Hey Google, tell master bedroom volume up 6 times”
“Hey Google, tell living room left 3 times”
“Hey Google, tell master bedroom to mute”
There’s no support for launching or ending activities, didn’t see a need since it’s easy to turn them on or off already using either GH/SmartThings integration or GH/IFTTT/Harmony integration.
Much credit goes to sushilks from GitHub, he developed the js utilities for Harmony, I just created a simple web server that accepts GET requests and calls certain functions in his harmony-hub-util app. Alexa/Echo users may want to check out his alexaHarmonyApp, it uses a custom Alexa skill rather than IFTTT+CoRE to accomplish the same thing. I was using this with my Echo Dot until I got it working through GH.
This setup is probably not going to be a good solution for a casual or non-techie SmartThings user because it requires setting up an internal web server and most likely modifying the command set that I’ve included to customize it for your needs.
If that doesn’t scare you, read on…
Here’s how it works:
-
You execute an IFTTT applet using Google Assistant.
-
IFTTT triggers it’s Maker channel to make a web request to CoRE running on your SmartThings account, passing along your command, destination IP address for your Harmony hub, and a command counter (like volume up 5, left 3, etc) as variables.
-
CoRE, acting as the gateway between the internet and your internal network, takes the incoming request and stores the included variable values, then turns around and makes a web request to your internal web server, passing along the same variable values.
-
The web server application captures the variable values from the CoRE web request and passes them to the harmony-hub-util application to issue the proper commands to your Harmony hub.
Pre-requisites:
- IFTTT account, with Google Assistant and Maker channels activated
- Computer on your local network that stays turned on, logged in, and connected to your local network all the time. This will be your internal web server. note - all of my instructions are based on my experiences setting this up on a Raspberry Pi. Theoretically it should be possible on a Windows machine or a Mac, but additional steps may be necessary
- Node.js installed on your internal web server (download here: https://nodejs.org/en/download/)
- Static IP address for your internal web server and Harmony hub(s). Assign through your router.
- CoRE smartapp installed with dashboard enabled
Since there are many moving parts to this installation, I’m going to divide them up into phases. This will make the setup process easier, and testing at the end of each phase will make troubleshooting easier as well.
Phase 1 - get the web server up and running
-
Download the zip file from my GitHub site: https://github.com/destructure00/web-harmony. This is my first attempt at making my own app and sharing it on GitHub, so hopefully I didn’t mess it up.
-
Extract the zip file to whatever folder you want. I’m on a Raspberry Pi, extracted to /home/pi/web-harmony
-
Open a command/terminal window, navigate to your target folder, and run the command “npm install”. This will install the web server and it’s dependencies. It should go off and download the necessary dependencies for a minute or two, then drop you back at the prompt. You may get a warning message or two, hopefully no errors.
-
Start the web server by running “node server.js” in the same folder. You should get a message that it’s listening on port 8079. I have it set up to listen on this non-standard port to avoid conflicts with other web apps I have running. You can change this as needed by editing the server.js file.
-
Test to see if the web server is working correctly. Enter the following URL in a web browser:
http://(your web server ip):8079/remote?command=mute&count=1&harmony_ip=(your harmony ip)
. You should receive a response like the following:
If this is all working correctly, you’re ready for phase 2. If not, let me know in the comments below and we can troubleshoot.
Phase 2 - Create a CoRE piston to make requests to your internal web server
-
Create a new Basic piston
-
Initialize local variables command, count, and harmony_ip, all as strings. Values don’t matter right now (you can enter whatever you want), we just need them to exist so they can be added to your piston action.
-
Capability = IFTTT, Comparison = Executed, Value = harmony. Make sure you select the option to Import event data on true, this is what tells CoRE to store the incoming request values to variables.
-
Action = Make a web request, URL = http://{web server ip}:8079/remote, method = GET, content type = FORM, Variables to send - command, count, and harmony_ip
-
Save and exit
Here’s the final product:
Phase 3 - Create your IFTTT applets
Create your first applet to handle single-press commands like pause, play, select, menu, etc
-
“this” = Google Assistant
-
Select “Say a phrase with a text ingredient”.
-
In the “What do you want to say” section, enter “tell living room to $”. You can customize this as desired, change room name, etc.
-
If you want GH to repeat the command back to you, enter something like the following in the response section:
-
“that” = Maker, Make a web request
-
Open your CoRE dashboard in a separate tab in your browser. Copy the URL.
-
Paste the CoRE URL into the Maker URL field. At the end of the URL, Replace “dashboard#/” with “ifttt/harmony”
-
Set Method = GET, content type = application/json, body as shown, replacing my IP address with your Harmony hub IP address
Create your second applet to handle multiple-press commands like volume up 6, right 3, etc.
-
“this” = Google Assistant
-
Select “Say a phrase with both a number and a text ingredient”.
-
In the “What do you want to say” section, enter “tell living room $ # times”. You can customize this as desired, change room name, etc. I added the word times to the end because without it, google gets confused between numbers and words at the end, two/too, four/for. Adding another word at the end seems to have fixed this issue.
-
If you want GH to repeat the command back to you, enter something like the following in the response section:
-
“that” = Maker, Make a web request
-
Open your CoRE dashboard in a separate tab in your browser. Copy the URL.
-
Paste the CoRE URL into the Maker URL field. At the end of the URL, Replace “dashboard#/” with “ifttt/harmony”
-
Set Method = GET, content type = application/json, body as shown, replacing my IP address with your Harmony hub IP address
If you have additional Harmony hubs, repeat Phase 4 and change the room name and hub IP address. I have two Harmony hubs, so I have a total of 4 IFTTT applets. 2 start with “tell living room” and 2 start with “tell master bedroom”.
Phase 4 - customization
Commands are executed in the remote.js file. The last command received can always be viewed in the server.js terminal window or in CoRE by looking at the variable values. If you want to add additional phrases to execute existing commands, you can just add them to the switch block in remote.js. If you want to add new commands. I’d recommend installing harmonyHubCLI, also, from sushilks, and using that to find commands that are available for your activities. You can also download and dissect remote.js from his alexaHarmonyApp to see what other commands are available.
That should be it! Let me know if you run into trouble and I’ll try to help out.