Giter Club home page Giter Club logo

harmony-api's Introduction

Harmony API!!

Harmony API is a simple server allowing you to query/control multiple local Harmony Home Hubs and their devices over HTTP or MQTT.

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.

With MQTT, you can easily monitor the state of your devices as well as set the current activity of your hub or send specific commands per device. This makes it super easy to integrate into your existing home automation setup.

Features

  • 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.

Setup

script/bootstrap

Settings

Harmony API discovers your hubs automatically. You can optionally add your MQTT broker's host to connect to it.

{
  "mqtt_host": "mqtt://192.168.1.106",
  "mqtt_options": {
      "port": 1883,
      "username": "someuser",
      "password": "somepassword",
      "rejectUnauthorized": false
  },
  "topic_namespace": "home/harmony"
}

mqtt_options is optional, see the mqtt project for allowed host and options values.

Running It

Get up and running immediately with script/server.

Note:

On some distros, you might get an error when running it: /usr/bin/node: No such file or directory

That can probably be fixed by creating a symlink: sudo ln -s `which nodejs` /usr/bin/node

Harmony API will run on port 8282 by default. Use the PORT environment variable to use your own port.

Forever

harmony-api has support for Forever. It uses launchd on OS X to kick it off so that it starts on boot.

Development

You can simply run it by calling script/server. This will run it in development mode with logging to standard out.

Install as Service on OS X

script/install

Install as systemd unit on Linux

sudo script/install-linux

Docker

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" -v /path/to/your/config:/config \
    -p 8282:8282 -d jonmaddox/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 Hub IP address in config.json as hub_ip.

Logging

Harmony API logs all of its requests. In production, it logs to a file at log/logs.log. In development mode, it just logs to stdout.

How to Upgrade to 2.0

Simply run script/upgrade from the root of the project and Harmony API will upgrade to the newest version.

You are then going to have to change anything you integrate with Harmony API to reflect the change in HTTP endpoints and MQTT topics. Read the docs in this README to see how they have changed.

Development

Launch the app via script/server to run it in the development environment.

MQTT Docs

harmony-api can report its state changes to your MQTT broker. Just edit your config file in config/config.json to add your MQTT host and options.

By default harmony-api publishes topics with the namespace of: harmony-api. This can be overriden by setting topic_namespace in your config file.

State Topics

When the state changes on your harmony hub, state topics will be immediately broadcasted over your broker. There's quite a few topics that are broadcasted.

State topics are namespaced by your Harmony hub's name, as a slug. You can rename your hub in the Harmony app.

Here's a list:

Current State

This topic describes the current power state. Message is on or off.

harmony-api/hubs/family-room/state on

Current Activity

This topic describes what the current activity of the hub is. The message is the slug of an activity name.

harmony-api/hubs/family-room/current_activity watch-tv

Activity States

These topics describe the state of each activity that the hub has. The message is on or off. There will a topic for every activity on your hub.

harmony-api/hubs/family-room/activities/watch-tv/state off
harmony-api/hubs/family-room/activities/watch-apple-tv/state on
harmony-api/hubs/family-room/activities/play-xbox-one/state off

Command Topics

You can also command harmony-api to change activities, and issue device and acivity commands by publishing topics. harmony-api listens to these topics and will change to the activity, or issue the command when it sees it.

Switching activities

Just provide the slug of the hub and activity you want to switch to and on as the message. Any use of this topic with the message off will turn everything off.

harmony-api/hubs/family-room/activities/watch-tv/command on

Device commands

Just provide the slug of the hub and the device to control with the command you want to execute. harmony-api/hubs/family-room/devices/tv/command volume-down

To optionally repeat the command any number of times, provide an optional repeat integer. harmony-api/hubs/family-room/devices/tv/command volume-down:5

Current activity commands

Just provide the slug of the hub and the command you want to execute. harmony-api/hubs/family-room/command volume-down

To optionally repeat the command any number of times, provide an optional repeat integer. harmony-api/hubs/family-room/command volume-down:5

HTTP API Docs

This is a quick overview of the HTTP service. Read app.js if you need more info.

Resources

Here's a list of resources that may be returned in a response.

Activity Resource

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
}

Device Resource

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"
}

Command Resource

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"
}

Status Resource

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
  }
}

Methods

These are the endpoints you can hit to do things.

Info

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, ...]}

Control

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"}

Contributions

  • fork
  • create a feature branch
  • open a Pull Request

harmony-api's People

Contributors

jawilson avatar maddox avatar mehuman avatar nkgilley avatar svenove avatar terwey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

harmony-api's Issues

automation devices?

Thanks for your great project, I love it :)

I'm just missing a nice thing, that would be to automate home automation device attached to my harmony hub, for example my philips hue and scenes (ok bad example as hue lights already have an api, but I would only needs the commands available from my harmony hub).

Would it be possible?

http trigger not working

hi,
i have install the Harmony-API on my Synology, it works fine!
when i trigger a button over Terminal with:
curl --request POST http://192.168.1.100:8282/hubs/harmony/devices/rollos/commands/1-auf
it works fine!

i need to trigger it from http for a home bridge Plugin!

When I enter http://192.168.1.100:8282/hubs/harmony/devices/rollos/commands/1-auf in the browser i get an error ! Cannot GET /hubs/harmony/devices/rollos/commands/1-auf

what am I doing wrong?

i can only send the command by http for the plugin :-(

Many Thanks Jรผrgen

Devices in an activity

Wondering if you can help.

I have found that activity_commands does not list all the commands available.

Other Harmony API's list the devices.
"action":"{"command":"Jump","type":"IRCommand","deviceId":"999999"}"

For example
/hubs/my-room/activities/watch-tv/commands has less commands than
/hubs/my-room/devices/sony-tv/commands

But if I knew 'sony-tv' was used in the watch-tv activity I could just use the second action.

I made some progress. I can get the deviceid but not the slug.

For anyone interested here is what you edit

In the function getCommandsFromControlGroup

Add the below after slug =
var deviceId= func.action deviceId = deviceId.replace(/\D/g,''); deviceCommands[slug] = {name: func.name, slug: slug, label: func.label, "deviceId":deviceId}

Replace the existing deviceCommands[slug] with the one above. Now you know the id that relates to that command. Since I have many devices that control volume I wanted to know which one it was controlling.

Don't worry, will try and figure it out another way

Control devices

This looks like a great way to control a harmony hub but does it do devices also?

I currently just use my app to push commands via command line, activity control is easily done but device control has many more functions.

Granted mine is all manual, so I like the auto discovery yours has.

Feature Request: Go to channel endpoint

A possibly useful feature would be to have an endpoint that allows you to specify a channel to go to, something like:

POST harmony-api/hub/:hubSlug/command/tune/13.1

This would have to check that all of the keys are available, and then to send actions for all of them. This seems kind of out of place with the rest of the endpoints, but might be useful. Though I can see an argument for not including it in harmony-api, and rather relying on the caller to send individual commands. Though including it would facilitate one single request, rather than 3 or more, and would also allow for better IFTTT integration.

I'm willing to implement this in my fork and create a pull request, but wanted some feedback before I started.

Failing Overnight / 5 Second Updates (Docker)

Been running this in a Docker on my NAS for a short while to enable control in Home Assistant.

It works great when its running but it seams to stop running overnight every night.

My log has Updating state for lounge. every 5 seconds is this normal?

Below is the end of my log prior to failing. Any help would be appreciated.

Updating state for lounge.
stdout
20:55:10
Hub lost: Lounge at 192.168.0.12.
stdout
20:55:40
Hub discovered: Lounge at 192.168.0.12.
stdout
20:55:41
events.js:146
stderr
20:55:41
throw err;
stderr
20:55:41
^
stderr
20:55:41
stderr
20:55:41
Error: Uncaught, unspecified "error" event. (XMPP authentication failure)
stderr
20:55:41
at Client.emit (events.js:144:17)
stderr
20:55:41
at Client._handleAuthState (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/lib/Client.js:295:10)
stderr
20:55:41
at Client._handleStanza (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/lib/Client.js:233:12)
stderr
20:55:41
at Client.onStanza (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/lib/Client.js:221:8)
stderr
20:55:41
at emitOne (events.js:77:13)
stderr
20:55:41
at Connection.emit (events.js:169:7)
stderr
20:55:41
at Connection.onStanza (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/node_modules/node-xmpp-core/lib/Connection.js:377:10)
stderr
20:55:41
at StreamParser.<anonymous> (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/node_modules/node-xmpp-core/lib/Connection.js:231:10)
stderr
20:55:41
at emitOne (events.js:77:13)
stderr
20:55:41
at StreamParser.emit (events.js:169:7)
stderr
20:55:41
stderr
20:55:41
npm info [email protected] Failed to exec start script
stderr
20:55:41
npm ERR! Linux 3.10.35
stderr
20:55:41
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
stderr
20:55:41
npm ERR! node v4.6.0
stderr
20:55:41
npm ERR! npm v2.15.9
stderr
20:55:41
npm ERR! code ELIFECYCLE
stderr
20:55:41
npm ERR! [email protected] start: node app.js
stderr
20:55:41
npm ERR! Exit status 1
stderr
20:55:41
npm ERR!
stderr
20:55:41
npm ERR! Failed at the [email protected] start script 'node app.js'.
stderr
20:55:41
npm ERR! This is most likely a problem with the harmony-api package,
stderr
20:55:41
npm ERR! not with npm itself.
stderr
20:55:41
npm ERR! Tell the author that this fails on your system:
stderr
20:55:41
npm ERR! node app.js
stderr
20:55:41
npm ERR! You can get information on how to open an issue for this project with:
stderr
20:55:41
npm ERR! npm bugs harmony-api
stderr
20:55:41
npm ERR! Or if that isn't available, you can get their info via:
stderr
20:55:41
npm ERR!
stderr
20:55:41
npm ERR! npm owner ls harmony-api
stderr
20:55:41
npm ERR! There is likely additional logging output above.
stderr
20:55:41
stderr
20:55:41
npm ERR! Please include the following file with any support request:
stderr
20:55:41
npm ERR! /usr/src/app/npm-debug.log

Sending multiple POST commands

I understand this isn't the forum for technical support, but I am having trouble with sending multiple sequenced commands to my hub, and am not sure where the problem is.

I wrote a script to turn on an activity and then change the channel on my STB. If the activity is already on, the script works and it will change the channel successfully. If the harmony hub is off, or is set to a different activity, and the script needs to turn on, or change activities, and then send the commands to change channel, it will not work.

The first part works, it turns on / changes activity. I added a delay to the commands to change the channel in case that was the problem, this didn't change anything. When I send the commands, I do receive Response [200], so I know harmony-api is receiving the commands. It just looks like it is not relaying them properly? If I then run the script again after the hub / activity is on, it changes the channel correctly. Is there something I need to do to break the connection and resend the commands?

Init.d script

This is working for me but might need some refinements as I am not a unix expert.

Change user and folder depending on your usage. Assumes you have created a user called harmony and that the folder is accessible by that user

You can easily create this user with useradd --system harmony or choose a different name

File goes in /lib/systemd/system/harmony-api.service

[Unit]
Description=Harmony API
After=syslog.target network-online.target

[Service]
Type=simple
User=harmony
ExecStart=/harmony-api/script/server
Restart=on-failure
RestartSec=10
KillMode=process
PIDFile=/var/run/harmony-api.pid
StandardOutput=inherit 
StandardError=inherit 
SyslogIdentifier=harmony-api

[Install]
WantedBy=multi-user.target

Activities working, but unable to get commands working.

I'm able to run GET commands without issue such as
http://192.168.128.59:8282/hubs/harmony-hub/status runs fine.

Even PUT commands to turn off works great as follows:
http://192.168.128.59:8282/hubs/harmony-hub/off

But for some reason, I'm unable to get any of the POST commands to work correctly. Can someone sanity check that I'm calling these correctly, and also review the error I'm receiving in Postman when trying to run POST commands.

http://192.168.128.59:8282/hubs/harmony-hub/devices/sony-tv/commands/volume-down
Returns the following error:

at sendAction (/home/pi/harmony-api/app.js:373:19)
at /home/pi/harmony-api/app.js:532:5
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at next (/home/pi/harmony-api/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/pi/harmony-api/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at /home/pi/harmony-api/node_modules/express/lib/router/index.js:281:22
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:354:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)

http://192.168.128.59:8282/hubs/harmony-hub/commands/volume-down

at sendAction (/home/pi/harmony-api/app.js:373:19)
at app.put.hubSlug (/home/pi/harmony-api/app.js:483:5)
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at next (/home/pi/harmony-api/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/pi/harmony-api/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/pi/harmony-api/node_modules/express/lib/router/layer.js:95:5)
at /home/pi/harmony-api/node_modules/express/lib/router/index.js:281:22
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:354:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)
at param (/home/pi/harmony-api/node_modules/express/lib/router/index.js:365:14)

docker run fails

After building docker image from Dockerfile, it fails to run. Receive the following output...

npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info prestart [email protected]
npm info start [email protected]

> [email protected] start /usr/src/app
> node app.js

/usr/src/app/node_modules/mqtt/lib/connect/index.js:62
    opts.protocol = opts.protocol.replace(/\:$/, '');
                                 ^

TypeError: Cannot read property 'replace' of null
    at Object.connect (/usr/src/app/node_modules/mqtt/lib/connect/index.js:62:34)
    at Object.<anonymous> (/usr/src/app/app.js:27:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:974:3

npm info [email protected] Failed to exec start script
npm ERR! Linux 4.4.0-21-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node app.js'.
npm ERR! This is most likely a problem with the harmony-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs harmony-api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls harmony-api
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/src/app/npm-debug.log

Unsure how to progress forward. Recently built this about 30 days ago without any issues.

Launchd and PATH variable

I'm having an issue with the install script. I see it creates the plist file setting the PATH variable to this:
<key>PATH</key> <string>/usr/local/bin/:/usr/bin:$PATH</string>

Problem is, $PATH is not resolved since launchd is not able to resolve variables. This causes the execution of the command to not find "forever". I could hardcode my path to node but that doesn't look like a neat fix. Any ideas?

OSX Version: 10.12.3 (Sierra)

Unable to connect to hub

Hi there
I'm trying to get this working on in Windows environment. I've installed Nodejs and Git for Windows, ran the npm install without issue, but when I start it (npm start) it never discovers my Harmony Hub. I also manually defined my harmony hub info in the config.json, but it's still not finding it. The Windows machine Im running this on is on the same network as the Harmony hub.

Is there something else Im missing to get this working?

Thanks.

Hub Not discover

Hello,

Harmony-api don't detect my HUB (HTTP not MQTT), bellow the logs,

If i look in interface /hubs it send this message : {"message":"No hubs available."}

I need to make paring ? Hub version is : 4.12.36

With smartphone application, discover work witout problem.

[37m๏ฟฝ[40mnpm๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[32minfo๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[35mit worked if it ends with๏ฟฝ[0m ok
stdout
20:18:32
[0m๏ฟฝ[37m๏ฟฝ[40mnpm๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[32minfo๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[35musing๏ฟฝ[0m [email protected]
stdout
20:18:32
[0m๏ฟฝ[37m๏ฟฝ[40mnpm๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[32minfo๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[35musing๏ฟฝ[0m [email protected]
stdout
20:18:34
[0m๏ฟฝ[37m๏ฟฝ[40mnpm๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[32minfo๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[35mprestart๏ฟฝ[0m [email protected]
stdout
20:18:34
[0m๏ฟฝ[37m๏ฟฝ[40mnpm๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[32minfo๏ฟฝ[0m ๏ฟฝ[0m๏ฟฝ[35mstart๏ฟฝ[0m [email protected]
stdout
20:18:34
[0m
stdout
20:18:34
[email protected] start /usr/src/app
stdout
20:18:34
node app.js
stdout
20:18:34
stdout
20:18:39
Starting discovery.

hub restart crashes the script

if I restart a harmony hub to which the harmony-api connected, it crashes and forever doesn't seem to restart the script, it just stays stuck. example log:

Connecting to Harmony hub at 192.169.1.152
Updating activities.
Updating state.
Updating state.
Updating state.
Updating state.
Updating state.
Updating state.
Updating state.
Updating state.
events.js:160
throw er; // Unhandled 'error' event
^

Error: read ECONNRESET
at exports._errnoException (util.js:1007:11)
at TCP.onread (net.js:563:26)
error: Forever detected script exited with code: 1
error: Script restart attempt #1
Connecting to Harmony hub at 192.169.1.152
errorhub { Error: connect ECONNREFUSED 192.169.1.152:5222
at Object.exports._errnoException (util.js:1007:11)
at exports._exceptionWithHostPort (util.js:1030:20)
at TCPConnectWrap.afterConnect as oncomplete
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '192.169.1.152',
port: 5222 }

Any forums for discussion of harmony-api?

I just found out about this project and it will be very useful for me. Are there any online discussion forums for the community of users of this project? Or is there just the Issues in Github?

Example

Hi. Unfortunatly I'm unfamiliar with the technology you've used in this api. Got it up and running and I can get informasjon from the hub. But I would be very grateful if you could provide an example on how to post a command to the Harmony Hub from a webpage. Thank you very much in advance.

2.1 broken with fresh deps

After installing npm deps from scratch, it's suddenly doing this now:

Starting discovery.
Hub discovered: Bedroom at 192.168.1.109.
Hub discovered: Family Room at 192.168.1.106.
/Users/jmaddox/source/harmony-api/node_modules/harmonyhubjs-client/lib/login/hub.js:59
      if (response.identity && response.identity !== undefined) {
                  ^

TypeError: Cannot read property 'identity' of undefined
    at Client.<anonymous> (/Users/jmaddox/source/harmony-api/node_modules/harmonyhubjs-client/lib/login/hub.js:59:19)
    at emitOne (events.js:90:13)
    at Client.emit (events.js:182:7)
    at Client._handleStanza (/Users/jmaddox/source/harmony-api/node_modules/node-xmpp-client/lib/Client.js:227:12)
    at Client.onStanza (/Users/jmaddox/source/harmony-api/node_modules/node-xmpp-client/lib/Client.js:221:8)
    at emitOne (events.js:90:13)
    at Connection.emit (events.js:182:7)
    at Connection.onStanza (/Users/jmaddox/source/harmony-api/node_modules/node-xmpp-core/lib/Connection.js:377:10)
    at StreamParser.<anonymous> (/Users/jmaddox/source/harmony-api/node_modules/node-xmpp-core/lib/Connection.js:231:10)
    at emitOne (events.js:90:13)

HTTP Control help

server installed fine, running in development mode.
i can issue GET to get status and activities and hub responds properly.
trying to issue POST from postman - http://localhost:8282/start_activity?activity=watch-tv

responds with:

{
  "message": "Not Found"
}

(also, your README shows /start_activity?activity=, but when i connect to localhost:8282, the web page displays /start_activity?activity_name=. This isn't my problem as both of these yield same result as shown above.)

are there any headers required or any other suggestions?

First time docker run fails

Just pulled and attempted to run your docker and it failed to run. Config folder remains empty. The docker log is below. Am i doing something wrong?

npm info it worked if it ends with ok
stderr
11:27:17
npm info using [email protected]
stderr
11:27:17
npm info using [email protected]
stderr
11:27:17
npm info prestart [email protected]
stderr
11:27:17
npm info start [email protected]
stderr
11:27:17
stdout
11:27:17
> [email protected] start /usr/src/app
stdout
11:27:17
> node app.js
stdout
11:27:17
stdout
11:27:17
module.js:327
stderr
11:27:17
throw err;
stderr
11:27:17
^
stderr
11:27:17
stderr
11:27:17
Error: Cannot find module '/config/config.json'
stderr
11:27:17
at Function.Module._resolveFilename (module.js:325:15)
stderr
11:27:17
at Function.Module._load (module.js:276:25)
stderr
11:27:17
at Module.require (module.js:353:17)
stderr
11:27:17
at require (internal/module.js:12:17)
stderr
11:27:17
at Object.<anonymous> (/usr/src/app/app.js:11:14)
stderr
11:27:17
at Module._compile (module.js:409:26)
stderr
11:27:17
at Object.Module._extensions..js (module.js:416:10)
stderr
11:27:17
at Module.load (module.js:343:32)
stderr
11:27:17
at Function.Module._load (module.js:300:12)
stderr
11:27:17
at Function.Module.runMain (module.js:441:10)
stderr
11:27:17
stderr
11:27:17
npm info [email protected] Failed to exec start script
stderr
11:27:17
npm ERR! Linux 3.10.35
stderr
11:27:17
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
stderr
11:27:17
npm ERR! node v4.6.0
stderr
11:27:17
npm ERR! npm v2.15.9
stderr
11:27:17
npm ERR! code ELIFECYCLE
stderr
11:27:17
npm ERR! [email protected] start: node app.js
stderr
11:27:17
npm ERR! Exit status 1
stderr
11:27:17
npm ERR!
stderr
11:27:17
npm ERR! Failed at the [email protected] start script 'node app.js'.
stderr
11:27:17
npm ERR! This is most likely a problem with the harmony-api package,
stderr
11:27:17
npm ERR! not with npm itself.
stderr
11:27:17
npm ERR! Tell the author that this fails on your system:
stderr
11:27:17
npm ERR! node app.js
stderr
11:27:17
npm ERR! You can get information on how to open an issue for this project with:
stderr
11:27:17
npm ERR! npm bugs harmony-api
stderr
11:27:17
npm ERR! Or if that isn't available, you can get their info via:
stderr
11:27:17
npm ERR!
stderr
11:27:17
npm ERR! npm owner ls harmony-api
stderr
11:27:17
npm ERR! There is likely additional logging output above.
stderr
11:27:17
stderr
11:27:18
npm ERR! Please include the following file with any support request:
stderr
11:27:18
npm ERR! /usr/src/app/npm-debug.log

Stuck on "Starting Discovery" in development mod

I've installed on a full Ubuntu 16.04 distro (not docker). I can't install the production server so am attempting to run the script/server in development mode. In dev mode the script runs but never finds the Hub on my home network. I ran debug and get the message below. I've tried flushing IPtables but that doesn't help. The hub is working and discovered on my home network, just not through Harmony-API. Note, I'm not looking for MQTT functionality yet, just HTTP to begin with. Let me know if there are known issues or if you have ideas on how I can debug this problem and get the HTTP server working.

[email protected] start /home/chris/harmony-api-master
node app.js
Starting Discovery.

Request for assistance on installation on Synology NAS

I have been trying everything to get this up and running, I tried to use the standard installation tools from Synology for the container, but it will not start.

Does anyone have a step by step explanation how to install it on the Synology or is willing to help me?
(the explanation on the harmony-api page is not understandable by me).

Thanks in advance,
Udo

not a valid repository name

I'm trying to run bootstrap on my Raspberry Pi 1 B+ but npm is giving me the following errors:

npm ERR! git clone [email protected]:github:maddox/harmonyhubjs-client Cloning into bare repository '/home/pi/.npm/_git-remotes/git-github-com-github-maddox-harmonyhubjs-client-def8ff3d'...
npm ERR! git clone [email protected]:github:maddox/harmonyhubjs-client fatal: remote error:
npm ERR! git clone [email protected]:github:maddox/harmonyhubjs-client    is not a valid repository name
npm ERR! git clone [email protected]:github:maddox/harmonyhubjs-client   Email [email protected] for help
npm ERR! notarget No compatible version found: harmonyhubjs-client@'github:maddox/harmonyhubjs-client#for-harmony-api'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8","1.1.9","1.1.10"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! System Linux 4.9.41+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /tmp/harmony-api-2.3.5
npm ERR! node -v v4.8.2
npm ERR! npm -v 1.4.21
npm ERR! code ETARGET
npm ERR! Error: EACCES: permission denied, open 'npm-debug.log'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, open 'npm-debug.log']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path: 'npm-debug.log' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 4.9.41+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /tmp/harmony-api-2.3.5
npm ERR! node -v v4.8.2
npm ERR! npm -v 1.4.21
npm ERR! path npm-debug.log
npm ERR! syscall open
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! stack Error: EACCES: permission denied, open 'npm-debug.log'
npm ERR! stack     at Error (native)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /tmp/harmony-api-2.3.5/npm-debug.log
npm ERR! not ok code 0

As far as I know I have all the requirements installed. I also authenticated towards github.

Need to add pre-reqs to the readme.

The installation notes in the readme file do not mention that you first have to install npm and forever before you can install harmony-api. It says it has support forever but it doesn't say that you have to have forever running or else it will refuse to install. I ran the bootstrap script - and was told

echo "You don't have forever installed. You need to install it first."
echo
echo "Just install it with this command: "
echo 'sudo npm install forever -g'

Of course when you do the npm command it will fail if npm isn't installed.

The readme also doesn't talk about platforms although it does say "on some distros...". It should say that this should run on OS X and Linux, including Raspberry Pis. Will it run natively on Windows? Under the Ubuntu-Bash Shell on Windows 10?

Isssue with config.json

Hello everybody,

My hub was not found and i am trying to force it with "hub_ip".
but this is still not working, could somebody check the config.json and help?

here it is: config.json
{
"hub_ip": "10.10.10.11", "mqtt_host": "http://127.0.0.1",
"mqtt_options": {
"port": 1883,
"username": "someuser",
"password": "somepassword",
"rejectUnauthorized": false,
"hub_ip": "10.10.10.11"
}
}

is this ok? if yes then i do not know where to search. the hub is reachable from the container
thank you in advance
cheers

TypeError during discovery

Running in Docker with host networking and I get this error during discovery:

> [email protected] start /usr/src/app
> node app.js

Starting discovery.
Hub discovered: Living Room at 192.168.1.147.
/usr/src/app/node_modules/harmonyhubjs-client/lib/login/hub.js:59
if (response.identity && response.identity !== undefined) {
^

TypeError: Cannot read property 'identity' of undefined
at Client.<anonymous> (/usr/src/app/node_modules/harmonyhubjs-client/lib/login/hub.js:59:19)
at emitOne (events.js:77:13)
at Client.emit (events.js:169:7)
at Client._handleStanza (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/lib/Client.js:227:12)
at Client.onStanza (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/lib/Client.js:221:8)
at emitOne (events.js:77:13)
at Connection.emit (events.js:169:7)
at Connection.onStanza (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/node_modules/node-xmpp-core/lib/Connection.js:377:10)
at StreamParser.<anonymous> (/usr/src/app/node_modules/harmonyhubjs-client/node_modules/node-xmpp-client/node_modules/node-xmpp-core/lib/Connection.js:231:10)
at emitOne (events.js:77:13)

npm info [email protected] Failed to exec start script

Multiple Hubs?

I just started using this for Home Assistant and it seems to pull activities from both of my harmony hubs but for some reason only update 1 of them. Is the multiple hubs coming soon?? Looking forward to testing if you need anyone to help. Thanks again for all of your work! This is really great!

Recurring Syntax Error (unexpected token)?

Thanks so much for this software, I'm very thrilled this exists!

Many of my POST requests are failing as the hub is lost, devices are lost , device commands are lost. This is because of a recurring crash where the script is restarting over and over again. Sometimes the error happens so frequently that it's down more than it is up. Appears to be the same error each time. I have no idea what to do. Please advise, thank you!

The error is: "SyntaxError: Unexpected token ] in JSON at position 73682"

Here is what the output looks like..
"warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating activities for great-room.
Updating devices for great-room.
Updating state for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #1
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #2
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #3
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #4
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #5
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #6
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #7
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating activities for great-room.
Updating devices for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
Updating activities for great-room.
Updating devices for great-room.
Updating state for great-room.
Updating state for great-room.
Hub lost: Great Room at 192.168.0.11.
Hub discovered: Great Room at 192.168.0.11.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #8
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
Updating state for great-room.
Updating state for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #9
Starting discovery.
Hub discovered: Great Room at 192.168.0.11.
Updating activities for great-room.
Updating state for great-room.
Updating devices for great-room.
Updating state for great-room.
undefined:1
{"activity":[{"rules":[],"label":"Lower Screen","isTuningDefault":false,"activityTypeDisplayName":"Default","enterActions":[{"name":"SendCommand","parameters":{"Command":"directiondown","DeviceId":"49203209","Modifier":"press"}}],"fixit":{"49203207":{"id":"49203207","isRelativePower":true,"Power":"Off"},"49203209":{"id":"49203209","isAlwaysOn":"true","Power":"On"},"49203208":{"id":"49203208","Power":"Off"},"49920389":{"id":"49920389","isManualPower":true},"49920888":{"id":"49920888","Power":"Off"}},"baseImageUri":"https://rcbu-test-ssl-amr.s3.amazonaws.com/","zones":null,"type":"VirtualGeneric","isAVActivity":true,"id":"30232500","controlGroup":[{"name":"NavigationBasic","function":[{"action":"{"command":"DirectionDown","type":"IRCommand","deviceId":"49203209"}","name":"DirectionDown","label":"Direction Down"},{"action":"{"command":"DirectionUp","type":"IRCommand","deviceId":"49203209"}","name":"DirectionUp","label":"Direction Up"},{"action":"{"command":"OK","type

SyntaxError: Unexpected token ] in JSON at position 73682
at JSON.parse ()
at /home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:39:34
at Array.forEach (native)
at HarmonyClient.handleStanza (/home/harmony-api/harmony-api/node_modules/harmonyhubjs-client/lib/harmonyclient.js:31:32)
at emitOne (events.js:96:13)
at Client.emit (events.js:189:7)
at Client._handleStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:228:12)
at Client.onStanza (/home/harmony-api/harmony-api/node_modules/node-xmpp-client/lib/Client.js:222:8)
at emitOne (events.js:96:13)
at Connection.emit (events.js:189:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #10
Starting discovery.
Hub discovered: Great Room at 192.168.0.11."

And on and on it goes....

Securing HTTP requests

Is there a way to secure the HTTP endpoint, so authentication is required? I see the option for mqtt, but not http.

Having some trouble running

So I followed the directions and seemed to hit a brick wall. I got everything setp. I don't want to use it with mqtt can I remove that info from my config? Also how do I actually send the commands via Http, I am confused as to how I enter them into terminal. Can I just use CURL to query but am I suppose to be query localhost or the actual ip address of the hub?

Error: MAX_CLIENTS=6

This shows up in my error log. Some time recently Harmony increased the number of devices to 15 from 6. Can this be increased?

But even at that when I click GET hubs in the web UI it shows me 6 hubs in the JSON output. But on the web page it only lists 5 of the 5 hubs.

GET works POST wont. Please help

I've been trying to use this to integrate with Smartthings using a http button creater and although it will send all the GET commands, whatever I try I cannot get any POST commands I send get a 404 not found error. Could you please give a single line http POST example if possible.

Many thanks for your great work on this.

Cheers

harmony-api not accepting publish requests?

The following should turn off my system:

mosquitto_pub -d -u <username> -P <password> -t harmony-api/hubs/freds-harmony-hub/activities/watch-xbox-one/command -m off

It returns this:

Client mosqpub/2200-raspberryp sending CONNECT
Client mosqpub/2200-raspberryp received CONNACK
Client mosqpub/2200-raspberryp sending PUBLISH (d0, q0, r0, m1, 'harmony-api/hubs/freds-harmony-hub/activities/watch-xbox-one/command', ... (3 bytes))
Client mosqpub/2200-raspberryp sending DISCONNECT

But nothing happens.

This:

mosquitto_sub -v -h 'localhost' -u '<username>' -P '<password>' -t 'harmony-api/#'

...returns the list of activities, so watching seems to be working, just not publishing changes.

The switch as defined in MQTT is correctly reflecting the state but will not execute a command when manually flipped.

How do you limit the log file size?

I now have a Docker version of harmony-api running on my unRAID server. However I am concerned that the size of the log file will get very large. Is this managed or if you keep the service running with the log file get infinitely large?

It seems to me that the file grows by about 180kB/hour or so.

Or does it automatically flush the log file periodically?

Where is the log file

Hello,

i have started harmony-api as a service in systemctl. All runs very well. But where can i find the logs.log?
The folder /log is empty. thanks

Startup crash with v2.3.1

After updating to 2.3.1 and running npm update, I'm getting the following error:

Dec 01 14:07:55 ha node[24016]: Starting discovery.
Dec 01 14:07:55 ha node[24016]: /home/pi/harmony-api/app.js:101
Dec 01 14:07:55 ha node[24016]: activitySlug = harmonyHubStates[hubSlug].current_activity.slug
Dec 01 14:07:55 ha node[24016]: ^
Dec 01 14:07:55 ha node[24016]: TypeError: Cannot read property 'current_activity' of undefined
Dec 01 14:07:55 ha node[24016]: at MqttClient.<anonymous> (/home/pi/harmony-api/app.js:101:45)
Dec 01 14:07:55 ha node[24016]: at emitThree (events.js:97:13)
Dec 01 14:07:55 ha node[24016]: at MqttClient.emit (events.js:175:7)
Dec 01 14:07:55 ha node[24016]: at MqttClient._handlePublish (/home/pi/harmony-api/node_modules/mqtt/lib/client.js:792:12)
Dec 01 14:07:55 ha node[24016]: at MqttClient._handlePacket (/home/pi/harmony-api/node_modules/mqtt/lib/client.js:282:12)
Dec 01 14:07:55 ha node[24016]: at process (/home/pi/harmony-api/node_modules/mqtt/lib/client.js:238:12)
Dec 01 14:07:55 ha node[24016]: at MqttClient._handlePacket (/home/pi/harmony-api/node_modules/mqtt/lib/client.js:290:7)
Dec 01 14:07:55 ha node[24016]: at process (/home/pi/harmony-api/node_modules/mqtt/lib/client.js:238:12)
Dec 01 14:07:55 ha node[24016]: at Writable.writable._write (/home/pi/harmony-api/node_modules/mqtt/lib/client.js:248:5)
Dec 01 14:07:55 ha node[24016]: at doWrite (/home/pi/harmony-api/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:237:10)

Reverting back to 2.1.0 fixes things.

How do you run in production or install service in Linux?

The docs mentioning running in dev mode with script/server or installing on OSX with script/install.

But how do you install as a service on Linux - Ubuntu to be more specific?

Or how do you run in production on Linux? For now I have created a file called production that contains:
/usr/bin/env forever start config/forever/production.json.

The logging seems extremely verbose as while it is running it is constantly updating the state and writing this to the log file. If you keep this running 24/7 isn't the logs.log file going to get enormous? It seems to me that the log file will grow about 180kB/hour. Is it possible to decrease the verbosity so that only commands are logged?

Hub constistenly getting lost

I just installed harmony-api on a raspberry pi, amazing work...thank you.

My raspberry pi is connected via WIFI, my harmony hub never seems to have any issues, but it seems to be dropped pretty regularly from harmony-api, at which point harmony-api stops updating.

I don't see anyone else having this issue, any idea what might be going on and how I can fix it?

An example of the log:

Hub discovered: Harmony Hub at 192.168.1.58.
Updating state for harmony-hub
Updating state for harmony-hub
Updating state for harmony-hub
Hub discovered: undefined at undefined.
Updating state for harmony-hub
Updating state for harmony-hub
Hub lost: Harmony Hub at 192.168.1.58

Novice Installation

I am a novice. I want to send http commands from an applescript that is controlling iTunes on my Mac Mini to tell my harmony remote to execute activities based upon a change of state of iTunes...I have the iTunes part figured out in the applescript just not the Harmony Remote part. Essentially, a change of state would trigger an HTTP that would then execute an activity in the Harmony Remote. Unfortunately, I do not understand the instructions as listed...is there a more basic how-to I can read to understand how to install this API on my Mac Mini for use with my two Harmony Remote hubs and also include the format for the http command I would have applescript send? Thanks.

Repeat not working with HTTP call

Anyone else having issues getting repeat working? I have my ifttt maker channel setup with my google home and it's working but ?repeat=x doesn't work. No matter if i put 3 or 20 there, it only sends the command once.

multiple harmonyhubjs-discover running

I'm trying to get this thing running, but I'm having an issue with a homebridge plugin I'm using for harmony hub, which is running on the same machine, also uses harmonyhubjs-discover. Basically if i start to run script/server, it gives an error saying that port 5224 is already in use. any (good) idea how to solve this?

Improve config to bypass discovery

I'm having trouble with the auto-discovery in harmonyhubjs-discover in my setup and rather than fight it I thought it might be convenient to improve the config to support user specified hubs. I read through issue #36 and wasn't able to reproduce the iptable flushing, and I'm not sure that's the underlying root cause in my case - I'm running this on "Ubuntu on Windows" support in Windows 10 Anniversary Update. I know the IP of my hub and was able to make a local edit to hardcode my hub, but figured it might be nice to generalize this and contribute it back in case other users have difficulties with the discovery tool.

My thought is that I could extend config.json checking to support a list of hub-slug/ip pairs. Here are some things I could use input on:

  1. Verbose or compact syntax in the config. I could use a compact map of slug to IP:
harmony_hubs : {
  "living-room" : "192.168.1.3", 
  "bedroom" : "192.168.1.4",
}

which reads nicely once filled in, but isn't clearly documented. Or as

harmony_hubs : [
  { 
    "slug" : "living-room", 
    "ip" : "192.168.1.3" 
  }, 
  { 
    "slug" : "bedroom", 
    "ip" : "192.168.1.4" 
  },
]

which is less compact but more explicit.

  1. If hubs are specified, should discovery be enabled, disabled, or an option in the config? If an option, do you have a recommended parameter name?

  2. Are there any tests I would need to add?

Discovery fails

Hello,

I'm starting the script with /harmony-api/script/server on a RPi3 and it shows:

Starting Discovery.

but it never finds my Harmony hub. The hub is up and running and I can control it via HarmonyHubControl

How can I debug this behaviour? I see no errors at all.

How Do You Get Discovery Working In Docker?

Trying to use the Docker version. Works fine outside of Docker, but it won't discover the hubs. Tried mapping extra ports (docker-compose config), but it won't ever find the hubs.

ports:
  - 61991:61991
  - 61991:61991\udp
  - 5224:5224
  - 5224:5224\udp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.