Refactoring of reversely used group addresses

The use of 0/1 for binary objects depends on installation, a contact
sensor can have contact=1 or open=1
The same applies to percentages:  a window can be 100% closed or 100%
open.

For a more general usage of reversed values, a suffix ("R") can now be
attached to all DPT1 and DPT5 group addresses.
Please see updated KNX.md for examples and details.

Note: outdated characteristic-workaround throw an exception at boot-up:
-  ContactSensorStateContact1
-  LockCurrentStateSecured0
-  LockTargetStateSecured0
Please see error message and KNX.md for reference.
This commit is contained in:
Snowdd1
2015-10-02 18:05:40 +02:00
parent fd72307384
commit 3031ba7e0f
4 changed files with 127 additions and 92 deletions
+10 -7
View File
@@ -116,8 +116,8 @@ function groupsocketlisten(opts, callback) {
}
var registerSingleGA = function registerSingleGA (groupAddress, callback) {
subscriptions.push({address: groupAddress, callback: callback });
var registerSingleGA = function registerSingleGA (groupAddress, callback, reverse) {
subscriptions.push({address: groupAddress, callback: callback, reverse:reverse });
}
/*
@@ -143,7 +143,7 @@ var startMonitor = function startMonitor(opts) { // using { host: name-ip, port
if (subscriptions[i].address === dest) {
// found one, notify
console.log('HIT: Write from '+src+' to '+dest+': '+val+' ['+type+']');
subscriptions[i].callback(val, src, dest, type);
subscriptions[i].callback(val, src, dest, type, subscriptions[i].reverse);
}
}
});
@@ -156,7 +156,7 @@ var startMonitor = function startMonitor(opts) { // using { host: name-ip, port
if (subscriptions[i].address === dest) {
// found one, notify
// console.log('HIT: Response from '+src+' to '+dest+': '+val+' ['+type+']');
subscriptions[i].callback(val, src, dest, type);
subscriptions[i].callback(val, src, dest, type, subscriptions[i].reverse);
}
}
@@ -185,13 +185,16 @@ var registerGA = function (groupAddresses, callback) {
if (groupAddresses.constructor.toString().indexOf("Array") > -1) {
// handle multiple addresses
for (var i = 0; i < groupAddresses.length; i++) {
if (groupAddresses[i]) { // do not bind empty addresses
registerSingleGA (groupAddresses[i], callback);
if (groupAddresses[i] && groupAddresses[i].match(/(\d*\/\d*\/\d*)/)) { // do not bind empty addresses or invalid addresses
// clean the addresses
registerSingleGA (groupAddresses[i].match(/(\d*\/\d*\/\d*)/)[0], callback,groupAddresses[i].match(/\d*\/\d*\/\d*(R)/) ? true:false );
}
}
} else {
// it's only one
registerSingleGA (groupAddresses, callback);
if (groupAddresses.match(/(\d*\/\d*\/\d*)/)) {
registerSingleGA (groupAddresses.match(/(\d*\/\d*\/\d*)/)[0], callback, groupAddresses[i].match(/\d*\/\d*\/\d*(R)/) ? true:false);
}
}
// console.log("listeners now: " + subscriptions.length);
};