Harmony API is a simple server allowing you to query/control multiple local Harmony Home Hubs and their devices over HTTP
With HTTP, you can simply turn on and off activities, check hub status, and send commands to individual devices with simple HTTP requests from almost any other project.
- Control multiple Harmony hubs.
- List activities.
- Get current status, including if everything is off, or what the current activity is.
- Turn everything off.
- Start a specific activity.
- List devices.
- List device commands.
- Execute discrete commands for each device.
Harmony API will run on port 8282
by default. Use the PORT
environment
variable to use your own port.
For Manual Mode :
{
"enableHTTPserver": true,
"hubs": [
{
"name": "Living",
"ip": "192.168.5.200"
}
]
}
For Discovery Mode (default config) :
{
"enableHTTPserver": true,
}
Installation with Docker is straightforward. Adjust the following command so that
/path/to/your/config
points to the folder where your want to store your config and run it:
$ docker run --name="harmony-api" --net=host -v /path/to/your/config:/config -d adn182/harmony-api
This will launch Harmony API and serve the web interface from port 8282 on your Docker host. Hub
discovery requires host networking (--net=host
). However, you can specify your Harmony Hubs in
config.json
e.g.:
"hubs": [
{
"name": "Living Room",
"ip": "192.168.1.111"
},
{
"name": "Bedroom",
"ip": "192.168.1.112"
},
]
This is a quick overview of the HTTP service. Read app.js if you need more info.
Here's a list of resources that may be returned in a response.
The Activity resource returns all the information you really need for an Activity set up in your Harmony Hub.
{
"id": "15233552",
"slug": "watch-tv",
"label": "Watch TV",
"isAVActivity": true
}
The Device resource returns all the information you need to know about the devices set up for the hub.
{
"id": "38343689",
"slug": "tivo-premiere",
"label": "TiVo Premiere"
}
The Command resource returns all the information you really need for a Command to let you execute it.
{
"name": "ChannelDown",
"slug": "channel-down",
"label":"Channel Down"
}
The Status resource returns the current state of your Harmony Hub.
{
"off": false,
"current_activity": {
"id": "15233552",
"slug": "watch-tv",
"label": "Watch TV",
"isAVActivity": true
}
}
These are the endpoints you can hit to do things.
Use these endpoints to query the current state of your Harmony Hub.
GET /hubs => {"hubs": ["family-room", "bedroom"] }
GET /hubs/:hub_slug/status => StatusResource
GET /hubs/:hub_slug/commands => {"commands": [CommandResource, CommandResource, ...]}
GET /hubs/:hub_slug/activities => {"activities": [ActivityResource, ActivityResource, ...]}
GET /hubs/:hub_slug/activities/:activity_slug/commands => {"commands": [CommandResource, CommandResource, ...]}
GET /hubs/:hub_slug/devices => {"devices": [DeviceResource, DeviceResource, ...]}
GET /hubs/:hub_slug/devices/:device_slug/commands => {"commands": [CommandResource, CommandResource, ...]}
Use these endpoints to control your devices through your Harmony Hub.
PUT /hubs/:hub_slug/off => {message: "ok"}
POST /hubs/:hub_slug/commands/:command_slug => {message: "ok"}
POST /hubs/:hub_slug/commands/:command_slug?repeat=3 => {message: "ok"}
POST /hubs/:hub_slug/activities/:activity_slug => {message: "ok"}
POST /hubs/:hub_slug/devices/:device_slug/commands/:command_slug => {message: "ok"}
POST /hubs/:hub_slug/devices/:device_slug/commands/:command_slug?repeat=3 => {message: "ok"}