Control your devices connected to a Logitech™ Harmony Hub from Node-RED.
If you haven't done so yet, install Node-RED
sudo npm install -g node-red
There are two ways to install the extension: Via npm on the terminal or from within Node-RED in the browser.
In the terminal open the user data directory ˜/.node-red
and install the package
cd ˜/.node-red
npm install node-red-contrib-harmony
Then run or restart Node-RED
node-red
Open your Node-RED instance, typically under http://localhost:1880, and you should see the new nodes available in the palette in the group harmony.
You can install the extension simply in Node-RED in your browser, by default under http://localhost:1880. Click on the Menu button (sandwich icon) in the upper right corner. In the menu click Manage palette. In the side-panel that opens on the left click on the tab Install. In the search field enter harmony, in the result list a node-red-contrib-harmony card will appear. Click on the install button on this card, and you are done. You should now find the new nodes available in the palette in the group harmony.
Four nodes are available in Node-RED: H command, H activity, H device command and H observe, located in the group harmony.
A node to send a Command to a Harmony Hub through Node-RED.
A Harmony Hub needs to be selected from the list or created by clicking on the edit button. The Harmony Hub IP address can be autodetected by clicking on the search button in the configuration node.
An Activity that is set up on the Harmony Hub needs to be provided, it's identified by its ID. Clicking on the search button loads the available activities from the provided Hub, which can then be selected from a dropdown list. Switching back to the imput field will show the ID in the field. The Label field below will show the Activity label.
A Command from the selected Activity needs to be provided, it's a stanza query. Clicking on the search button loads the available commands from the provided Activity, that can then be selected from a list. Switching back to the input field will show the query string in the field.
The Repeat field allows for the command to be repeated. The default is 1, meaning the command is send once. For example entering 10 will send the command exactly 10 times. This can be helpful when using commands for volume or channels.
The command configured in the node will be triggered by any input injected into the node, the output slot will return msg.payload = true if the command was sent successfully.
A node to activate an Activity on a Harmony Hub through Node-RED
A Harmony Hub needs to be selected from the list or created by clicking on the edit button. The Harmony Hub IP address can be autodetected by clicking on the search button in the configuration node.
An Activity that is set up on the Harmony Hub needs to be provided, it's identified by its ID. Clicking on the search button loads the available activities from the provided Hub, which can then be selected from a dropdown list. Switching back to the input field will show the ID in the field. The Label field below will show the Activity label.
To switch off, select PowerOff from the Activity dropdown list, or enter "-1" into the field.
The command configured in the node will be triggered by any input injected into the node, the output slot will return msg.payload = true if the command was sent successfully.
A node to send a Device Command to a Harmony Hub through Node-RED.
A Harmony Hub needs to be selected from the list or created by clicking on the edit button. The Harmony Hub IP address can be autodetected by clicking on the search button in the configuration node.
A Device that is set up on the Harmony Hub needs to be provided, it's identified by its ID. Clicking on the search button loads the available devices from the provided Hub, which can then be selected from a dropdown list. Switching back to the imput field will show the ID in the field. The Label field below will show the Device label.
A Command from the selected Device needs to be provided, it's a stanza query. Clicking on the search button loads the available commands from the provided Device, that can then be selected from a list. Switching back to the input field will show the query string in the field.
The Repeat field allows for the command to be repeated. The default is 1, meaning the command is send once. For example entering 10 will send the command exactly 10 times. This can be helpful when using commands for volume or channels.
The command configured in the node will be triggered by any input injected into the node, the output slot will return msg.payload = true if the command was sent successfully
A node to observe an Activity being triggered on a Harmony Hub through Node-RED
A Harmony Hub needs to be selected from the list or created by clicking on the edit button. The Harmony Hub IP address can be autodetected by clicking on the search button in the configuration node.
When an Activity is switched on the Harmony Hub, the node sends an object with a payload to the output:
payload: { activityId: activityId, activityStatus: activityStatus }
The activityId is the ID of the current activity, the activityStatus represents the following states:
0 = Hub is off, 1 = Activity is starting, 2 = Activity is started, 3 = Hub is turning off
- NodeJS - JavaScript runtime built on Chrome's V8 JavaScript engine.
- Node-RED - for wiring together hardware devices, APIs and online services.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
- Stefan Krüger - Initial work - Aietes
- Daniel Freese - Coding help - AirBorne04
This project is licensed under the MIT License - see the LICENSE.md file for details
This Node-RED module is based on the great work of Manuel Alabor - swissmanu, using his harmonyhubjs-client and harmonyhubjs-discover libraries.