mirror of
https://github.com/mtan93/homebridge.git
synced 2026-05-08 14:26:04 +01:00
Added Get-State Function
This commit is contained in:
@@ -30,7 +30,31 @@ HomeMatic.prototype = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getPowerState: function(callback) {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
this.log("Getting Power State of CCU");
|
||||||
|
request.get({
|
||||||
|
url: "http://"+this.ccuIP+"/config/xmlapi/state.cgi?datapoint_id="+this.ccuID,
|
||||||
|
}, function(err, response, body) {
|
||||||
|
|
||||||
|
if (!err && response.statusCode == 200) {
|
||||||
|
|
||||||
|
//that.log("Response:"+response.body);
|
||||||
|
var responseString = response.body.substring(83,87);
|
||||||
|
//that.log(responseString);
|
||||||
|
switch(responseString){
|
||||||
|
case "true": {modvalue = "1";break;}
|
||||||
|
case "fals": {modvalue = "0";break;}
|
||||||
|
}
|
||||||
|
callback(parseInt(modvalue));
|
||||||
|
that.log("Getting Power State complete.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
that.log("Error '"+err+"' getting Power State: " + body);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
getServices: function() {
|
getServices: function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
return [{
|
return [{
|
||||||
@@ -101,6 +125,7 @@ HomeMatic.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(callback); },
|
||||||
perms: ["pw","pr","ev"],
|
perms: ["pw","pr","ev"],
|
||||||
format: "bool",
|
format: "bool",
|
||||||
initialValue: false,
|
initialValue: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user