mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 21:02:38 +00: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() {
|
||||
var that = this;
|
||||
return [{
|
||||
@@ -101,6 +125,7 @@ HomeMatic.prototype = {
|
||||
},{
|
||||
cType: types.POWER_STATE_CTYPE,
|
||||
onUpdate: function(value) { that.setPowerState(value); },
|
||||
onRead: function(callback) { that.getPowerState(callback); },
|
||||
perms: ["pw","pr","ev"],
|
||||
format: "bool",
|
||||
initialValue: false,
|
||||
|
||||
Reference in New Issue
Block a user