Stream Deck: Integrating Harmony Hub

The latest batch file "integration" I've gotten up and running for the Elgato Stream Deck is my Logitech Harmony Hub. The Harmony Hub allows for Home Entertainment (TV / Home Audio / Media Player) automation. While most Harmony remotes are fancy, touchscreen learning IR remotes, the Harmony Hub is a network device that centralizes home entertainment and wraps it in a nice API for us to interface with. As with my previous Philips Hue integration, I'm using batch files running node.js scripts to achieve control of the Harmony Hub.

Step 1.) Install Node.js

First things first, if you haven't already installed node.js, download the latest "recommended for most users" release of node.js here: https://nodejs.org/ and follow their instructions to install.

Step 2.) Install Git for Windows

Some of the harmonyhub client packages will try to use git to download components, so you will need to have git available on your system. If you have not already installed Git, you can download and install Git for Windows from: https://git-for-windows.github.io/

Step 3.) Install npm packages & harmonyHubCli

Now you'll need to install some node packages and scripts to provide our interface to the Harmony Hub. The code we are installing is from these 4 git repositories:

To test that harmonyHubCli is ready to run, open a command window from the folder you stored harmonyHubCli.js in and enter: node harmonyHubCli.js -r activities. The script will search for Harmony Hubs on your network and return the IP and then a list of actions available via that Harmony Hub. For future commands we'll use the IP returned here directly so that this search step doesn't have to repeat.
To list individual devices on associated with your Harmony Hub, enter: node harmonyHubCli.js -l YOUR_HARMONY_HUB_IP_HERE -r devices
To list commands we can send to any given device, enter: node harmonyHubCli.js -l YOUR_HARMONY_HUB_IP_HERE -d "YOUR_DEVICE_NAME_HERE" -r commands
To send one of these commands to the device, enter: node harmonyHubCli.js -l YOUR_HARMONY_HUB_IP_HERE -d "YOUR_DEVICE_NAME_HERE" -c "YOUR_COMMAND_NAME_HERE"

Now that we have Harmony interacting properly with the command line, we can wrap up some simple commands in batch files and tie them to "Open" buttons on the Stream Deck. First we'll create a plain text file called MuteTv.bat in the same directory where we stored harmonyHubCli.js. Editing this file, we'll use the IP and an appropriate device name from our testing in Step 4 to craft a mute button. My hub IP is 192.168.1.160, my device name is Sharp TV and my command name is Mute, so my batch file command will be: node C:\nircmd\scripts\harmony\harmonyHubCli.js -l 192.168.1.160 -d "Sharp TV" -c "Mute". I've also fully qualified the path to harmonyHubCli.js, because we will invoke via nircmd to suppress the command window, the path will get obfuscated and needs to be fully qualified here.

Lastly, from the Stream Deck software, create a new "Open" type button form the "System" button category and point the App / File field at your batch file. You'll need to make sure you have nircmd (http://www.nirsoft.net/utils/nircmd.html) and prepend your call to your batch file with nircmd exec hide to prevent the command window from showing (as of Stream Deck 1.1.2). For more details see my previous Stream Deck integration. On my system, my finished button command looks like C:\nircmd\nircmd.exe exec hide C:\nircmd\scripts\harmony\MuteTv.bat. Your mute button should now be working properly. You can mine out other devices or activities you want to control and wire them up similarly.