From 643c24937d14ef4bb4e923e4ed3e2c72e7d6938d Mon Sep 17 00:00:00 2001 From: Jan Bobolz Date: Sat, 21 Oct 2017 11:15:51 +0200 Subject: [PATCH] Fix issue #8 --- harmony/harmony-server.js | 5 +++++ harmony/harmony.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/harmony/harmony-server.js b/harmony/harmony-server.js index 7bc630b..1248772 100644 --- a/harmony/harmony-server.js +++ b/harmony/harmony-server.js @@ -1,5 +1,6 @@ var HarmonyHubDiscover = require('harmonyhubjs-discover') var harmonyClient = require('harmonyhubjs-client') +var events = require('events') module.exports = function (RED) { function HarmonyServerNode (n) { @@ -7,6 +8,7 @@ module.exports = function (RED) { var node = this node.ip = n.ip + node.harmonyEventEmitter = new events.EventEmitter() createClient(node) this.on('close', function () { @@ -29,6 +31,9 @@ module.exports = function (RED) { } harmonyClient(ip).then(function (harmony) { node.harmony = harmony + harmony.on('stateDigest', function(digest) { + node.harmonyEventEmitter.emit('stateDigest', digest) + }) !(function keepAlive () { harmony.request('getCurrentActivity').timeout(50000).then(function (response) { setTimeout(keepAlive, 50000) diff --git a/harmony/harmony.js b/harmony/harmony.js index 51080d0..afbfde0 100644 --- a/harmony/harmony.js +++ b/harmony/harmony.js @@ -89,8 +89,8 @@ module.exports = function (RED) { setTimeout(function () { try { - node.server.harmony.on('stateDigest', function (digest) { - // console.log(JSON.stringify(digest)); + node.server.harmonyEventEmitter.on('stateDigest', function (digest) { + // console.log(JSON.stringify(digest)); try { node.send({ payload: {