got it straight

does not use PR#15 for node-eibd any more.
This commit is contained in:
Snowdd1
2015-09-04 16:35:11 +02:00
parent bad0ba0c3b
commit 1a98a6c9ac
2 changed files with 23 additions and 11 deletions

View File

@@ -6,6 +6,8 @@
var Service = require("HAP-NodeJS").Service;
var Characteristic = require("HAP-NodeJS").Characteristic;
var knxd = require("eibd");
var knxd_registerGA = require('../platforms/KNX.js').registerGA;
var knxd_startMonitor = require('../platforms/KNX.js').startMonitor;
@@ -21,6 +23,10 @@ function KNXlampAccessory(log, config) {
this.brightness_listen_addresses = config.brightness_listen_addresses;
this.knxd_ip = config.knxd_ip ; // eg 127.0.0.1 if running on localhost
this.knxd_port = config.knxd_port || 6720; // eg 6720 default knxd port
if (config.name) {
this.name = config.name;
}
log("Accessory constructor called");
}
@@ -90,7 +96,7 @@ KNXlampAccessory.prototype = {
knxregister: function(addresses, characteristic) {
console.log("knx registering " + addresses);
knxd.registerGA(addresses, function(value){
knxd_registerGA(addresses, function(value){
// parameters do not match
this.log("Getting value from bus:"+value);
characteristic.setValue(value, undefined, 'fromKNXBus');
@@ -174,7 +180,7 @@ KNXlampAccessory.prototype = {
this.knxregister(this.brightness_addresses, brightnessCharacteristic);
this.knxread(this.brightness_group_address); // issue a read request on the bus, maybe the device answers to that!
}
knxd.startMonitor({ host: this.knxd_ip, port: this.knxd_port });
knxd_startMonitor({ host: this.knxd_ip, port: this.knxd_port });
return [informationService, lightbulbService];
}
};

View File

@@ -4,7 +4,7 @@
'use strict';
var types = require("HAP-NodeJS/accessories/types.js");
//var hardware = require('myHardwareSupport'); //require any additional hardware packages
var Connection = require('eibd').connection;
var knxd = require('eibd');
function KNXPlatform(log, config){
this.log = log;
@@ -17,9 +17,9 @@ function KNXPlatform(log, config){
};
MyPlatform.prototype = {
KNXPlatform.prototype = {
accessories: function(callback) {
this.log("Fetching myPlatform devices.");
this.log("Fetching KNX devices.");
var that = this;
@@ -34,11 +34,16 @@ MyPlatform.prototype = {
var myAccessories = [];
for (var int = 0; int < foundAccessories.length; int++) {
this.log("parsing acc " + int + " of " + foundAccessories.length);
// instantiate and push to array
if (foundAccessories[i].accessory-type === "knxlamp") {
myAccessories.push(new require('../accessories/knxlamp.js').accessory(this.log,foundAccessories[i]));
if (foundAccessories[int].accessory_type === "knxlamp") {
this.log("push new lamp with "+foundAccessories[int].name);
foundAccessories[int].knxd_ip = this.config.knxd_ip;
foundAccessories[int].knxd_port = this.config.knxd_port;
var accConstructor = require('./../accessories/knxlamp.js');
var acc = new accConstructor.accessory(this.log,foundAccessories[int]);
this.log("created "+acc.name+" accessory");
myAccessories.push(acc);
} else {
// do something else
this.log("unkown accessory type found")
@@ -46,6 +51,7 @@ MyPlatform.prototype = {
};
// if done, return the array to callback function
this.log("returning "+myAccessories.length+" accessories");
callback(myAccessories);
}
};
@@ -118,7 +124,7 @@ var subscriptions = [];
var running;
function groupsocketlisten(opts, callback) {
var conn = Connection();
var conn = knxd.Connection();
conn.socketRemote(opts, function() {
conn.openGroupSocket(0, callback);
});
@@ -201,6 +207,6 @@ var registerGA = function (groupAddresses, callback) {
module.exports.platform = myPlatform;
module.exports.platform = KNXPlatform;
module.exports.registerGA = registerGA;
module.exports.startMonitor = startMonitor;