mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-28 06:06:25 +01:00
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:
+10
-7
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user