mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 21:02:38 +00:00
Merge commit '2652f33a0a2de8566df0d346ec19c2bc1ceaff9d' into feature/Harmony
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
"xmldoc": "0.1.x",
|
||||
"komponist" : "0.1.0",
|
||||
"yamaha-nodejs": "0.4.x",
|
||||
"debug": "^2.2.0"
|
||||
"debug": "^2.2.0",
|
||||
"node-xmpp-client": "1.0.0-alpha23"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,14 @@ LogitechHarmonyPlatform.prototype = {
|
||||
.then(function (client) {
|
||||
self.log("Connected to Logitech Harmony remote hub");
|
||||
|
||||
// prevent connection from closing
|
||||
setTimeout(function() {
|
||||
setInterval(function() {
|
||||
self.log("Sending command to prevent timeout");
|
||||
client.getCurrentActivity();
|
||||
}, 20000);
|
||||
}, 5000);
|
||||
|
||||
callback(null, client);
|
||||
});
|
||||
};
|
||||
@@ -163,9 +171,9 @@ LogitechHarmonyAccessory.prototype = {
|
||||
var self = this;
|
||||
|
||||
if (this.isActivity) {
|
||||
hub.getCurrentActivity().then(function (currentActivity) {
|
||||
callback(currentActivity.id === self.id);
|
||||
}).except(function (err) {
|
||||
this.hub.getCurrentActivity().then(function (currentActivity) {
|
||||
callback(currentActivity === self.id);
|
||||
}).catch(function (err) {
|
||||
self.log('Unable to get current activity with error', err);
|
||||
callback(false);
|
||||
});
|
||||
@@ -175,28 +183,23 @@ LogitechHarmonyAccessory.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
setPowerState: function (state, callback) {
|
||||
setPowerState: function (state) {
|
||||
var self = this;
|
||||
|
||||
if (this.isActivity) {
|
||||
this.log('Set activity ' + this.name + ' power state to ' + state);
|
||||
|
||||
// Activity id -1 is turn off all devices
|
||||
var id = state ? this.id : -1;
|
||||
|
||||
this.hub.startActivity(id)
|
||||
this.hub.startActivity(self.id)
|
||||
.then(function () {
|
||||
self.log('Finished setting activity ' + self.name + ' power state to ' + state);
|
||||
callback();
|
||||
})
|
||||
.catch(function (err) {
|
||||
self.log('Failed setting activity ' + self.name + ' power state to ' + state + ' with error ' + err);
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
// TODO: Support setting device power
|
||||
this.log('TODO: Support setting device power');
|
||||
callback();
|
||||
// callback();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -284,7 +287,9 @@ LogitechHarmonyAccessory.prototype = {
|
||||
onUpdate: function (value) {
|
||||
self.setPowerState(value)
|
||||
},
|
||||
onRead: self.getPowerState,
|
||||
onRead: function(callback) {
|
||||
self.getPowerState(callback)
|
||||
},
|
||||
perms: ["pw","pr","ev"],
|
||||
format: "bool",
|
||||
initialValue: 0,
|
||||
@@ -300,6 +305,5 @@ LogitechHarmonyAccessory.prototype = {
|
||||
|
||||
};
|
||||
|
||||
module.exports.accessory = LogitechHarmonyAccessory;
|
||||
module.exports.platform = LogitechHarmonyPlatform;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user