mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-21 06:13:11 +01:00
Merge pull request #64 from hachidorii/master
Add support for getting the state of the power to WeMo accessories.
This commit is contained in:
@@ -54,6 +54,28 @@ WeMoAccessory.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getPowerState: function(callback) {
|
||||||
|
|
||||||
|
if (!this.device) {
|
||||||
|
this.log("No '"+this.wemoName+"' device found (yet?)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
this.log("checking power state for: " + this.wemoName);
|
||||||
|
this.device.getBinaryState(function(err, result) {
|
||||||
|
if (!err) {
|
||||||
|
var binaryState = parseInt(result)
|
||||||
|
that.log("power state for " + that.wemoName + " is: " + binaryState)
|
||||||
|
callback(binaryState)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
that.log(err)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
getServices: function() {
|
getServices: function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
return [{
|
return [{
|
||||||
@@ -124,6 +146,11 @@ WeMoAccessory.prototype = {
|
|||||||
},{
|
},{
|
||||||
cType: types.POWER_STATE_CTYPE,
|
cType: types.POWER_STATE_CTYPE,
|
||||||
onUpdate: function(value) { that.setPowerState(value); },
|
onUpdate: function(value) { that.setPowerState(value); },
|
||||||
|
onRead: function(callback) {
|
||||||
|
that.getPowerState(function(powerState){
|
||||||
|
callback(powerState);
|
||||||
|
});
|
||||||
|
},
|
||||||
perms: ["pw","pr","ev"],
|
perms: ["pw","pr","ev"],
|
||||||
format: "bool",
|
format: "bool",
|
||||||
initialValue: false,
|
initialValue: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user