mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 05:31:55 +00:00
cleanup formatting
This commit is contained in:
committed by
Stefan Kuper
parent
6b36ec9dc4
commit
7623bf4204
@@ -1,3 +1,4 @@
|
|||||||
|
"use strict";
|
||||||
//
|
//
|
||||||
// Homematic Platform Shim for HomeBridge
|
// Homematic Platform Shim for HomeBridge
|
||||||
//
|
//
|
||||||
@@ -7,13 +8,13 @@
|
|||||||
|
|
||||||
|
|
||||||
var types = require("hap-nodejs/accessories/types.js");
|
var types = require("hap-nodejs/accessories/types.js");
|
||||||
var xmlrpc = require('homematic-xmlrpc')
|
var xmlrpc = require("homematic-xmlrpc");
|
||||||
|
|
||||||
var request = require("request");
|
var request = require("request");
|
||||||
var http = require("http");
|
var http = require("http");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var HomeMaticGenericChannel = require(path.resolve(__dirname, 'HomematicChannel.js'));
|
var HomeMaticGenericChannel = require(path.resolve(__dirname, "HomematicChannel.js"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -28,29 +29,29 @@ RegaRequest.prototype = {
|
|||||||
|
|
||||||
var post_options = {
|
var post_options = {
|
||||||
host: this.ccuIP,
|
host: this.ccuIP,
|
||||||
port: '80',
|
port: "80",
|
||||||
path: '/tclrega.exe',
|
path: "/tclrega.exe",
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
'Content-Length': script.length
|
"Content-Length": script.length
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var post_req = http.request(post_options, function(res) {
|
var post_req = http.request(post_options, function(res) {
|
||||||
var data = "";
|
var data = "";
|
||||||
res.setEncoding('binary');
|
res.setEncoding("binary");
|
||||||
res.on('data', function(chunk) {
|
res.on("data", function(chunk) {
|
||||||
data += chunk.toString();
|
data += chunk.toString();
|
||||||
});
|
});
|
||||||
res.on('end', function() {
|
res.on("end", function() {
|
||||||
var pos = data.lastIndexOf("<xml><exec>");
|
var pos = data.lastIndexOf("<xml><exec>");
|
||||||
var response = (data.substring(0, pos));
|
var response = (data.substring(0, pos));
|
||||||
callback(response);
|
callback(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
post_req.on('error', function(e) {
|
post_req.on("error", function(e) {
|
||||||
callback("{}");
|
callback("{}");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -65,23 +66,24 @@ RegaRequest.prototype = {
|
|||||||
|
|
||||||
var script = "var d = dom.GetObject(\"" + channel + "." + datapoint + "\");if (d){Write(d.State());}";
|
var script = "var d = dom.GetObject(\"" + channel + "." + datapoint + "\");if (d){Write(d.State());}";
|
||||||
//that.log("Rega Request " + script);
|
//that.log("Rega Request " + script);
|
||||||
var regarequest = this.script(script, function(data) {
|
this.script(script, function(data) {
|
||||||
that.log("Rega Response" + data);
|
that.log("Rega Response" + data);
|
||||||
if (data != undefined) {
|
if (data !== undefined) {
|
||||||
callback(parseFloat(data));
|
callback(parseFloat(data));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(channel, datapoint, value) {
|
setValue: function(channel, datapoint, value) {
|
||||||
var that = this;
|
|
||||||
|
|
||||||
var script = "var d = dom.GetObject(\"" + channel + "." + datapoint + "\");if (d){d.State(\"" + value + "\");}";
|
var script = "var d = dom.GetObject(\"" + channel + "." + datapoint + "\");if (d){d.State(\"" + value + "\");}";
|
||||||
//that.log("Rega Request " + script);
|
//this.log("Rega Request " + script);
|
||||||
var regarequest = this.script(script, function(data) {});
|
this.script(script, function(data) {
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
function HomematicRPC(log, ccuip, platform) {
|
function HomematicRPC(log, ccuip, platform) {
|
||||||
this.log = log;
|
this.log = log;
|
||||||
@@ -106,29 +108,29 @@ HomematicRPC.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.localIP = ip;
|
this.localIP = ip;
|
||||||
this.log("Local IP: " + this.localIP)
|
this.log("Local IP: " + this.localIP);
|
||||||
|
|
||||||
this.server = xmlrpc.createServer({
|
this.server = xmlrpc.createServer({
|
||||||
host: this.localIP,
|
host: this.localIP,
|
||||||
port: 9090
|
port: 9090
|
||||||
})
|
|
||||||
|
|
||||||
this.server.on('NotFound', function(method, params) {
|
|
||||||
that.log('Method ' + method + ' does not exist');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.server.on('system.listMethods', function(err, params, callback) {
|
this.server.on("NotFound", function(method, params) {
|
||||||
that.log('Method call params for \'system.listMethods\': ' + params)
|
that.log("Method " + method + " does not exist");
|
||||||
callback(null, ['system.listMethods', 'system.multicall']);
|
});
|
||||||
|
|
||||||
|
this.server.on("system.listMethods", function(err, params, callback) {
|
||||||
|
that.log("Method call params for 'system.listMethods': " + params);
|
||||||
|
callback(null, ["system.listMethods", "system.multicall"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.server.on('system.multicall', function(err, params, callback) {
|
this.server.on("system.multicall", function(err, params, callback) {
|
||||||
params.map(function(events) {
|
params.map(function(events) {
|
||||||
try {
|
try {
|
||||||
events.map(function(event) {
|
events.map(function(event) {
|
||||||
if ((event["methodName"] == "event") && (event['params'] != undefined)) {
|
if ((event["methodName"] == "event") && (event["params"] !== undefined)) {
|
||||||
var params = event['params'];
|
var params = event["params"];
|
||||||
var channel = "BidCos-RF." + params[1];
|
var channel = "BidCos-RF." + params[1];
|
||||||
var datapoint = params[2];
|
var datapoint = params[2];
|
||||||
var value = params[3];
|
var value = params[3];
|
||||||
@@ -144,11 +146,11 @@ HomematicRPC.prototype = {
|
|||||||
callback(null);
|
callback(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.log('XML-RPC server listening on port 9090')
|
this.log("XML-RPC server listening on port 9090");
|
||||||
this.connect();
|
this.connect();
|
||||||
|
|
||||||
|
|
||||||
process.on('SIGINT', function() {
|
process.on("SIGINT", function() {
|
||||||
if (that.stopping) {
|
if (that.stopping) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -156,7 +158,7 @@ HomematicRPC.prototype = {
|
|||||||
that.stop();
|
that.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('SIGTERM', function() {
|
process.on("SIGTERM", function() {
|
||||||
if (that.stopping) {
|
if (that.stopping) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -167,29 +169,28 @@ HomematicRPC.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getIPAddress: function() {
|
getIPAddress: function() {
|
||||||
var interfaces = require('os').networkInterfaces();
|
var interfaces = require("os").networkInterfaces();
|
||||||
for (var devName in interfaces) {
|
for (var devName in interfaces) {
|
||||||
var iface = interfaces[devName];
|
var iface = interfaces[devName];
|
||||||
for (var i = 0; i < iface.length; i++) {
|
for (var i = 0; i < iface.length; i++) {
|
||||||
var alias = iface[i];
|
var alias = iface[i];
|
||||||
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal)
|
if (alias.family === "IPv4" && alias.address !== "127.0.0.1" && !alias.internal)
|
||||||
return alias.address;
|
return alias.address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '0.0.0.0';
|
return "0.0.0.0";
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function(channel, datapoint, callback) {
|
getValue: function(channel, datapoint, callback) {
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
if (this.client == undefined) {
|
if (this.client === undefined) {
|
||||||
that.log("Returning cause client is invalid");
|
that.log("Returning cause client is invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (channel.indexOf("BidCos-RF.") > -1) {
|
if (channel.indexOf("BidCos-RF.") > -1) {
|
||||||
channel = channel.substr(10);
|
channel = channel.substr(10);
|
||||||
this.log("Calling rpc getValue");
|
this.client.methodCall("getValue", [channel, datapoint], function(error, value) {
|
||||||
this.client.methodCall('getValue', [channel, datapoint], function(error, value) {
|
|
||||||
callback(value);
|
callback(value);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -200,41 +201,41 @@ HomematicRPC.prototype = {
|
|||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
if (this.client == undefined) return;
|
if (this.client === undefined) return;
|
||||||
|
|
||||||
if (channel.indexOf("BidCos-RF.") > -1) {
|
if (channel.indexOf("BidCos-RF.") > -1) {
|
||||||
channel = channel.substr(10);
|
channel = channel.substr(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.methodCall('setValue', [channel, datapoint, value], function(error, value) {
|
this.client.methodCall("setValue", [channel, datapoint, value], function(error, value) {
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
connect: function() {
|
connect: function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
this.log('Creating Local HTTP Client for CCU RPC Events');
|
this.log("Creating Local HTTP Client for CCU RPC Events");
|
||||||
this.client = xmlrpc.createClient({
|
this.client = xmlrpc.createClient({
|
||||||
host: this.ccuip,
|
host: this.ccuip,
|
||||||
port: 2001,
|
port: 2001,
|
||||||
path: '/'
|
path: "/"
|
||||||
});
|
});
|
||||||
this.log('CCU RPC Init Call on port 2001');
|
this.log("CCU RPC Init Call on port 2001");
|
||||||
this.client.methodCall('init', ['http://' + this.localIP + ':9090', 'homebridge'], function(error, value) {
|
this.client.methodCall("init", ["http://" + this.localIP + ":9090", "homebridge"], function(error, value) {
|
||||||
that.log('CCU Response ....')
|
that.log("CCU Response ....");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
stop: function() {
|
stop: function() {
|
||||||
this.log("Removing Event Server");
|
this.log("Removing Event Server");
|
||||||
this.client.methodCall('init', ['http://' + this.localIP + ':9090'], function(error, value) {
|
this.client.methodCall("init", ["http://" + this.localIP + ":9090"], function(error, value) {
|
||||||
|
|
||||||
});
|
});
|
||||||
setTimeout(process.exit(0), 1000);
|
setTimeout(process.exit(0), 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
function HomeMaticPlatform(log, config) {
|
function HomeMaticPlatform(log, config) {
|
||||||
@@ -267,35 +268,35 @@ HomeMaticPlatform.prototype = {
|
|||||||
|
|
||||||
var regarequest = new RegaRequest(this.log, this.ccuIP).script(script, function(data) {
|
var regarequest = new RegaRequest(this.log, this.ccuIP).script(script, function(data) {
|
||||||
var json = JSON.parse(data);
|
var json = JSON.parse(data);
|
||||||
if (json['devices'] != undefined) {
|
if (json["devices"] !== undefined) {
|
||||||
json['devices'].map(function(device) {
|
json["devices"].map(function(device) {
|
||||||
var isFiltered = false;
|
var isFiltered = false;
|
||||||
|
|
||||||
if ((that.filter_device != undefined) && (that.filter_device.indexOf(device.address) > -1)) {
|
if ((that.filter_device !== undefined) && (that.filter_device.indexOf(device.address) > -1)) {
|
||||||
isFiltered = true;
|
isFiltered = true;
|
||||||
} else {
|
} else {
|
||||||
isFiltered = false;
|
isFiltered = false;
|
||||||
}
|
}
|
||||||
// that.log('device address:', device.address);
|
// that.log('device address:', device.address);
|
||||||
|
|
||||||
if ((device['channels'] != undefined) && (!isFiltered)) {
|
if ((device["channels"] !== undefined) && (!isFiltered)) {
|
||||||
|
|
||||||
device['channels'].map(function(ch) {
|
device["channels"].map(function(ch) {
|
||||||
var isChannelFiltered = false;
|
var isChannelFiltered = false;
|
||||||
|
|
||||||
if ((that.filter_channel != undefined) && (that.filter_channel.indexOf(ch.address) > -1)) {
|
if ((that.filter_channel !== undefined) && (that.filter_channel.indexOf(ch.address) > -1)) {
|
||||||
isChannelFiltered = true;
|
isChannelFiltered = true;
|
||||||
} else {
|
} else {
|
||||||
isChannelFiltered = false;
|
isChannelFiltered = false;
|
||||||
}
|
}
|
||||||
// that.log('name', ch.name, ' -> address:', ch.address);
|
// that.log('name', ch.name, ' -> address:', ch.address);
|
||||||
if ((ch.address != undefined) && (!isChannelFiltered)) {
|
if ((ch.address !== undefined) && (!isChannelFiltered)) {
|
||||||
|
|
||||||
if ((ch.type == "SWITCH") || (ch.type == "BLIND") || (ch.type == "SHUTTER_CONTACT") || (ch.type == "DIMMER") || (ch.type == "CLIMATECONTROL_RT_TRANSCEIVER") || (ch.type == "MOTION_DETECTOR") || (ch.type == "KEYMATIC")) {
|
if ((ch.type == "SWITCH") || (ch.type == "BLIND") || (ch.type == "SHUTTER_CONTACT") || (ch.type == "DIMMER") || (ch.type == "CLIMATECONTROL_RT_TRANSCEIVER") || (ch.type == "MOTION_DETECTOR") || (ch.type == "KEYMATIC")) {
|
||||||
// Switch found
|
// Switch found
|
||||||
// Check if marked as Outlet
|
// Check if marked as Outlet
|
||||||
var special = (that.outlets.indexOf(ch.address) > -1) ? 'OUTLET' : undefined;
|
var special = (that.outlets.indexOf(ch.address) > -1) ? "OUTLET" : undefined;
|
||||||
accessory = new HomeMaticGenericChannel(that.log, that, ch.id, ch.name, ch.type, ch.address, special);
|
var accessory = new HomeMaticGenericChannel(that.log, that, ch.id, ch.name, ch.type, ch.address, special);
|
||||||
that.foundAccessories.push(accessory);
|
that.foundAccessories.push(accessory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,14 +371,14 @@ HomeMaticPlatform.prototype = {
|
|||||||
script = script + command;
|
script = script + command;
|
||||||
});
|
});
|
||||||
this.sendQueue = [];
|
this.sendQueue = [];
|
||||||
//this.log("RegaSend: " + script);
|
//this.log('RegaSend: ' + script);
|
||||||
var regarequest = new RegaRequest(this.log, this.ccuIP).script(script, function(data) {});
|
var regarequest = new RegaRequest(this.log, this.ccuIP).script(script, function(data) {});
|
||||||
},
|
},
|
||||||
|
|
||||||
sendRequest: function(accessory, script, callback) {
|
sendRequest: function(accessory, script, callback) {
|
||||||
var that = this;
|
|
||||||
var regarequest = new RegaRequest(this.log, this.ccuIP).script(script, function(data) {
|
var regarequest = new RegaRequest(this.log, this.ccuIP).script(script, function(data) {
|
||||||
if (data != undefined) {
|
if (data !== undefined) {
|
||||||
try {
|
try {
|
||||||
var json = JSON.parse(data);
|
var json = JSON.parse(data);
|
||||||
callback(json);
|
callback(json);
|
||||||
@@ -399,11 +400,11 @@ HomeMaticPlatform.prototype = {
|
|||||||
var that = this;
|
var that = this;
|
||||||
this.delayed[delay] = setTimeout(function() {
|
this.delayed[delay] = setTimeout(function() {
|
||||||
clearTimeout(that.delayed[delay]);
|
clearTimeout(that.delayed[delay]);
|
||||||
that.sendPreparedRequests()
|
that.sendPreparedRequests();
|
||||||
}, delay ? delay : 100);
|
}, delay ? delay : 100);
|
||||||
this.log("New Timer was set");
|
this.log("New Timer was set");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
"use strict";
|
||||||
var types = require("hap-nodejs/accessories/types.js");
|
var types = require("hap-nodejs/accessories/types.js");
|
||||||
|
|
||||||
|
|
||||||
@@ -21,9 +22,7 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
|
|
||||||
// Return current States
|
// Return current States
|
||||||
query: function(dp, callback) {
|
query: function(dp, callback) {
|
||||||
var that = this;
|
if (this.state[dp] !== undefined) {
|
||||||
|
|
||||||
if (this.state[dp] != undefined) {
|
|
||||||
callback(this.state[dp]);
|
callback(this.state[dp]);
|
||||||
} else {
|
} else {
|
||||||
// that.log("No cached Value found start fetching and send temp 0 back");
|
// that.log("No cached Value found start fetching and send temp 0 back");
|
||||||
@@ -34,7 +33,7 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
dpvalue: function(dp, fallback) {
|
dpvalue: function(dp, fallback) {
|
||||||
if (this.state[dp] != undefined) {
|
if (this.state[dp] !== undefined) {
|
||||||
return (this.state[dp]);
|
return (this.state[dp]);
|
||||||
} else {
|
} else {
|
||||||
return fallback;
|
return fallback;
|
||||||
@@ -66,8 +65,8 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
reverse: function(value) {
|
reverse: function(value) {
|
||||||
if (value == "true") return "false";
|
if (value == "true") return "false";
|
||||||
if (value == "false") return "true";
|
if (value == "false") return "true";
|
||||||
if (value == 0) return 1;
|
if (value === 0) return 1;
|
||||||
if (value == 1) return 0;
|
if (value === 1) return 0;
|
||||||
if (value == "0") return "1";
|
if (value == "0") return "1";
|
||||||
if (value == "1") return "0";
|
if (value == "1") return "0";
|
||||||
return value;
|
return value;
|
||||||
@@ -76,11 +75,11 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
cache: function(dp, value) {
|
cache: function(dp, value) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
if ((that.reverseDP[dp] != undefined) && (that.reverseDP[dp] == true)) {
|
if ((that.reverseDP[dp] !== undefined) && (that.reverseDP[dp] === true)) {
|
||||||
value = that.reverse(value);
|
value = that.reverse(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (that.currentStateCharacteristic[dp] != undefined) {
|
if (that.currentStateCharacteristic[dp] !== undefined) {
|
||||||
that.currentStateCharacteristic[dp].updateValue(value, null);
|
that.currentStateCharacteristic[dp].updateValue(value, null);
|
||||||
}
|
}
|
||||||
this.state[dp] = value;
|
this.state[dp] = value;
|
||||||
@@ -89,7 +88,7 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
|
|
||||||
delayed: function(mode, dp, value, delay) {
|
delayed: function(mode, dp, value, delay) {
|
||||||
|
|
||||||
if (this.eventupdate == true) {
|
if (this.eventupdate === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,13 +101,13 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
var that = this;
|
var that = this;
|
||||||
this.delayed[delay] = setTimeout(function() {
|
this.delayed[delay] = setTimeout(function() {
|
||||||
clearTimeout(that.delayed[delay]);
|
clearTimeout(that.delayed[delay]);
|
||||||
that.command(mode, dp, value)
|
that.command(mode, dp, value);
|
||||||
}, delay ? delay : 100);
|
}, delay ? delay : 100);
|
||||||
},
|
},
|
||||||
|
|
||||||
command: function(mode, dp, value, callback) {
|
command: function(mode, dp, value, callback) {
|
||||||
|
|
||||||
if (this.eventupdate == true) {
|
if (this.eventupdate === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -170,12 +169,12 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Identify Accessory",
|
manfDescription: "Identify Accessory",
|
||||||
designedMaxLength: 1
|
designedMaxLength: 1
|
||||||
}]
|
}];
|
||||||
},
|
},
|
||||||
|
|
||||||
controlCharacteristics: function(that) {
|
controlCharacteristics: function(that) {
|
||||||
|
|
||||||
cTypes = [{
|
var cTypes = [{
|
||||||
cType: types.NAME_CTYPE,
|
cType: types.NAME_CTYPE,
|
||||||
onUpdate: null,
|
onUpdate: null,
|
||||||
perms: ["pr"],
|
perms: ["pr"],
|
||||||
@@ -185,14 +184,14 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Name of service",
|
manfDescription: "Name of service",
|
||||||
designedMaxLength: 255
|
designedMaxLength: 255
|
||||||
}]
|
}];
|
||||||
|
|
||||||
|
|
||||||
if (this.type == "SWITCH") {
|
if (this.type == "SWITCH") {
|
||||||
cTypes.push({
|
cTypes.push({
|
||||||
cType: types.POWER_STATE_CTYPE,
|
cType: types.POWER_STATE_CTYPE,
|
||||||
onUpdate: function(value) {
|
onUpdate: function(value) {
|
||||||
that.command("set", "STATE", (value == 1) ? true : false)
|
that.command("set", "STATE", (value == 1) ? true : false);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRead: function(callback) {
|
onRead: function(callback) {
|
||||||
@@ -228,37 +227,37 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Is Outlet in Use",
|
manfDescription: "Is Outlet in Use",
|
||||||
designedMaxLength: 1
|
designedMaxLength: 1
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.type == "KEYMATIC") {
|
if (this.type == "KEYMATIC") {
|
||||||
cTypes.push({
|
cTypes.push({
|
||||||
cType: types.CURRENT_LOCK_MECHANISM_STATE_CTYPE,
|
cType: types.CURRENT_LOCK_MECHANISM_STATE_CTYPE,
|
||||||
|
|
||||||
onRead: function(callback) {
|
onRead: function(callback) {
|
||||||
that.query("STATE", callback);
|
that.query("STATE", callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRegister: function(characteristic) {
|
onRegister: function(characteristic) {
|
||||||
that.currentStateCharacteristic["STATE"] = characteristic;
|
that.currentStateCharacteristic["STATE"] = characteristic;
|
||||||
characteristic.eventEnabled = true;
|
characteristic.eventEnabled = true;
|
||||||
that.remoteGetValue("STATE");
|
that.remoteGetValue("STATE");
|
||||||
},
|
},
|
||||||
|
|
||||||
perms: ["pr", "ev"],
|
perms: ["pr", "ev"],
|
||||||
format: "bool",
|
format: "bool",
|
||||||
initialValue: that.dpvalue("STATE", 0),
|
initialValue: that.dpvalue("STATE", 0),
|
||||||
supportEvents: false,
|
supportEvents: false,
|
||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Current State of your Lock",
|
manfDescription: "Current State of your Lock",
|
||||||
designedMaxLength: 1
|
designedMaxLength: 1
|
||||||
}, {
|
}, {
|
||||||
cType: types.TARGET_LOCK_MECHANISM_STATE_CTYPE,
|
cType: types.TARGET_LOCK_MECHANISM_STATE_CTYPE,
|
||||||
|
|
||||||
onUpdate: function(value) {
|
onUpdate: function(value) {
|
||||||
that.command("set", "STATE", (value == 1) ? "true" : "false")
|
that.command("set", "STATE", (value == 1) ? "true" : "false");
|
||||||
},
|
},
|
||||||
|
|
||||||
onRead: function(callback) {
|
onRead: function(callback) {
|
||||||
@@ -280,13 +279,13 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Target State of your Lock",
|
manfDescription: "Target State of your Lock",
|
||||||
designedMaxLength: 1
|
designedMaxLength: 1
|
||||||
}
|
},
|
||||||
|
|
||||||
, {
|
{
|
||||||
cType: types.TARGET_DOORSTATE_CTYPE,
|
cType: types.TARGET_DOORSTATE_CTYPE,
|
||||||
|
|
||||||
onUpdate: function(value) {
|
onUpdate: function(value) {
|
||||||
that.command("set", "OPEN", "true")
|
that.command("set", "OPEN", "true");
|
||||||
},
|
},
|
||||||
|
|
||||||
onRead: function(callback) {
|
onRead: function(callback) {
|
||||||
@@ -307,17 +306,13 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
designedMaxLength: 1
|
designedMaxLength: 1
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (this.type == "DIMMER") {
|
if (this.type == "DIMMER") {
|
||||||
cTypes.push({
|
cTypes.push({
|
||||||
cType: types.POWER_STATE_CTYPE,
|
cType: types.POWER_STATE_CTYPE,
|
||||||
onUpdate: function(value) {
|
onUpdate: function(value) {
|
||||||
that.command("set", "LEVEL", (value == true) ? "1" : "0")
|
that.command("set", "LEVEL", (value == true) ? "1" : "0");
|
||||||
},
|
},
|
||||||
|
|
||||||
onRead: function(callback) {
|
onRead: function(callback) {
|
||||||
@@ -369,29 +364,29 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
|
|
||||||
if (this.type == "BLIND") {
|
if (this.type == "BLIND") {
|
||||||
cTypes.push({
|
cTypes.push({
|
||||||
cType: types.WINDOW_COVERING_CURRENT_POSITION_CTYPE,
|
cType: types.WINDOW_COVERING_CURRENT_POSITION_CTYPE,
|
||||||
|
|
||||||
onRead: function(callback) {
|
onRead: function(callback) {
|
||||||
that.query("LEVEL", callback);
|
that.query("LEVEL", callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRegister: function(characteristic) {
|
onRegister: function(characteristic) {
|
||||||
that.currentStateCharacteristic["LEVEL"] = characteristic;
|
that.currentStateCharacteristic["LEVEL"] = characteristic;
|
||||||
characteristic.eventEnabled = true;
|
characteristic.eventEnabled = true;
|
||||||
that.remoteGetValue("LEVEL");
|
that.remoteGetValue("LEVEL");
|
||||||
},
|
},
|
||||||
|
|
||||||
perms: ["pr", "ev"],
|
perms: ["pr", "ev"],
|
||||||
format: "int",
|
format: "int",
|
||||||
initialValue: that.dpvalue("LEVEL", 0),
|
initialValue: that.dpvalue("LEVEL", 0),
|
||||||
supportEvents: false,
|
supportEvents: false,
|
||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Current Blind Position",
|
manfDescription: "Current Blind Position",
|
||||||
designedMinValue: 0,
|
designedMinValue: 0,
|
||||||
designedMaxValue: 100,
|
designedMaxValue: 100,
|
||||||
designedMinStep: 1,
|
designedMinStep: 1,
|
||||||
unit: "%"
|
unit: "%"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
cType: types.WINDOW_COVERING_TARGET_POSITION_CTYPE,
|
cType: types.WINDOW_COVERING_TARGET_POSITION_CTYPE,
|
||||||
@@ -497,16 +492,16 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
if (this.type == "CLIMATECONTROL_RT_TRANSCEIVER") {
|
if (this.type == "CLIMATECONTROL_RT_TRANSCEIVER") {
|
||||||
|
|
||||||
cTypes.push({
|
cTypes.push({
|
||||||
cType: types.NAME_CTYPE,
|
cType: types.NAME_CTYPE,
|
||||||
onUpdate: null,
|
onUpdate: null,
|
||||||
perms: ["pr"],
|
perms: ["pr"],
|
||||||
format: "string",
|
format: "string",
|
||||||
initialValue: this.name,
|
initialValue: this.name,
|
||||||
supportEvents: true,
|
supportEvents: true,
|
||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Name of service",
|
manfDescription: "Name of service",
|
||||||
designedMaxLength: 255
|
designedMaxLength: 255
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
cType: types.CURRENTHEATINGCOOLING_CTYPE,
|
cType: types.CURRENTHEATINGCOOLING_CTYPE,
|
||||||
@@ -550,8 +545,7 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
characteristic.eventEnabled = true;
|
characteristic.eventEnabled = true;
|
||||||
that.remoteGetValue("ACTUAL_TEMPERATURE");
|
that.remoteGetValue("ACTUAL_TEMPERATURE");
|
||||||
},
|
},
|
||||||
perms: ["pw", "pr", "ev"],
|
perms: ["pr", "ev"],
|
||||||
perms: ["pr"],
|
|
||||||
format: "double",
|
format: "double",
|
||||||
initialValue: that.dpvalue("ACTUAL_TEMPERATURE", 20),
|
initialValue: that.dpvalue("ACTUAL_TEMPERATURE", 20),
|
||||||
supportEvents: false,
|
supportEvents: false,
|
||||||
@@ -602,7 +596,7 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return cTypes
|
return cTypes;
|
||||||
},
|
},
|
||||||
|
|
||||||
sType: function() {
|
sType: function() {
|
||||||
@@ -633,12 +627,12 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.type == "MOTION_DETECTOR") {
|
if (this.type == "MOTION_DETECTOR") {
|
||||||
return types.MOTION_SENSOR_STYPE
|
return types.MOTION_SENSOR_STYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.type == "KEYMATIC") {
|
if (this.type == "KEYMATIC") {
|
||||||
return types.LOCK_MECHANISM_STYPE
|
return types.LOCK_MECHANISM_STYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -649,12 +643,12 @@ HomeMaticGenericChannel.prototype = {
|
|||||||
var that = this;
|
var that = this;
|
||||||
var services = [{
|
var services = [{
|
||||||
sType: types.ACCESSORY_INFORMATION_STYPE,
|
sType: types.ACCESSORY_INFORMATION_STYPE,
|
||||||
characteristics: this.informationCharacteristics(),
|
characteristics: this.informationCharacteristics()
|
||||||
}, {
|
}, {
|
||||||
sType: this.sType(),
|
sType: this.sType(),
|
||||||
characteristics: this.controlCharacteristics(that)
|
characteristics: this.controlCharacteristics(that)
|
||||||
}];
|
}];
|
||||||
this.log("Loaded services for " + this.name)
|
this.log("Loaded services for " + this.name);
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user