Skip to content

Commit

Permalink
New version 0.2.6 which contains a new flag for avoiding sending READ
Browse files Browse the repository at this point in the history
requests for "Set" group addresses.
  • Loading branch information
snowdd1 committed Dec 1, 2015
1 parent 734cc81 commit 9f59e92
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 157 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
0.2.3 deprecated config.json entry "accessory_type":"knxdevice" (not evalutated any more)
0.2.4 merged bugfix for surplus "break;" from github user EIBHomeControl - thanks!
0.2.5 added missing Outlet service; restored lost uuid_base attribute
0.2.6 added new flag knxd_do_not_read_set_groups=true to config.json to avoid sending read requests for SET group addresses

285 changes: 152 additions & 133 deletions KNX-sample-config.json
Original file line number Diff line number Diff line change
@@ -1,151 +1,170 @@
{
"bridge": {
"name": "Homebridge",
"username": "CC:22:3D:E3:CE:30",
"port": 51826,
{
"bridge": {
"name": "Homebridge",
"username": "CC:22:3D:E3:CE:30",
"port": 51826,
"pin": "031-45-154"
},
"description": "This is an example configuration file for KNX platform shim",
"hint": "Always paste into jsonlint.com validation page before starting your homebridge, saves a lot of frustration",
"hint2": "Replace all group addresses by current addresses of your installation, these are arbitrary examples!",
"hint3": "For valid services and their characteristics have a look at the KNX.md file in folder platforms!",
"hint99":"Everything that is named description or hint is not used by homebridge but decriptive only, you may change or remove at will",
"platforms": [
{
"platform": "KNX",
"name": "KNX",
"knxd_ip": "192.168.1.1",
"knxd_port": 6720,
"accessories": [
{
"description": "Only generic type knxdevice is supported, all previous knx types have been merged into that.",
"name": "Living Room North Lamp",
"services": [
{
"type": "Lightbulb",
"description": "iOS8 Lightbulb type, supports On (Switch) and Brightness",
"name": "Living Room North Lamp",
"On": {
"Set": "1/1/6",
"Listen": [
},

"description": "This is an example configuration file for KNX platform shim",
"hint": "Always paste into jsonlint.com validation page before starting your homebridge, saves a lot of frustration",
"hint2": "Replace all group addresses by current addresses of your installation, these are arbitrary examples!",
"hint3": "For valid services and their characteristics have a look at the KNX.md file in folder platforms!",
"hint99": "Everything that is named description or hint is not used by homebridge but decriptive only, you may change or remove at will",
"platforms": [
{
"platform": "KNX",
"name": "KNX",
"knxd_ip": "192.168.1.1",
"knxd_port": 6720,
"knxd_do_not_read_set_groups": true,
"hint_knxd_do_not_read_set_groups": "true if homebridge must not send read requests to Set addresses",
"accessories": [
{
"description": "Only generic type knxdevice is supported, all previous knx types have been merged into that.",
"name": "Living Room North Lamp",
"services": [
{
"type": "Lightbulb",
"description": "iOS8 Lightbulb type, supports On (Switch) and Brightness",
"name": "Living Room North Lamp",
"On": {
"Set": "1/1/6",
"Listen": [
"1/1/63"
]
},
"Brightness": {
"Set": "1/1/62",
"Listen": [
]
},

"Brightness": {
"Set": "1/1/62",
"Listen": [
"1/1/64"
]
}
}
],
]
}
}
],

"services-description": "Services is an array, you CAN have multiple service types in one accessory, though it is not fully supported in many iOS HK apps, such as EVE and myTouchHome"
},
{
"name": "Office Temperature",
"description": "iOS8.4.1 TemperatureSensor type, supports CurrentTemperature",
"services": [
{
"type": "TemperatureSensor",
"name": "Raumtemperatur",
"CurrentTemperature": {
},

{
"name": "Office Temperature",
"description": "iOS8.4.1 TemperatureSensor type, supports CurrentTemperature",
"services": [
{
"type": "TemperatureSensor",
"name": "Raumtemperatur",
"CurrentTemperature": {
"Listen": "3/3/44"
}
}
]
},
{
"name": "Office Window Lock",
"services": [
{
"type": "LockMechanism",
"description": "iOS8 Lock mechanism, Supports LockCurrentState, LockTargetState, append R to the addresses if LOCKED is 1",
"name": "Office Window Lock",
"LockCurrentState": {
}
}
]
},

{
"name": "Office Window Lock",
"services": [
{
"type": "LockMechanism",
"description": "iOS8 Lock mechanism, Supports LockCurrentState, LockTargetState, append R to the addresses if LOCKED is 1",
"name": "Office Window Lock",
"LockCurrentState": {
"Listen": "5/3/15R"
},
"LockTargetState": {
},

"LockTargetState": {
"Listen": "5/3/16R"
}
}
]
},
{
"description": "sample device with multiple services. Multiple services of different types are widely supported",
"name": "Office",
"services": [
{
"type": "Lightbulb",
"name": "Office Lamp",
"On": {
}
}
]
},

{
"description": "sample device with multiple services. Multiple services of different types are widely supported",
"name": "Office",
"services": [
{
"type": "Lightbulb",
"name": "Office Lamp",
"On": {
"Set": "1/3/5"
}
},
{
"type": "Thermostat",
"description": "iOS8 Thermostat type, supports CurrentTemperature, TargetTemperature, CurrentHeatingCoolingState ",
"name": "Raumtemperatur",
"CurrentTemperature": {
}
},

{
"type": "Thermostat",
"description": "iOS8 Thermostat type, supports CurrentTemperature, TargetTemperature, CurrentHeatingCoolingState ",
"name": "Raumtemperatur",
"CurrentTemperature": {
"Listen": "3/3/44"
},
"TargetTemperature": {
},

"TargetTemperature": {
"Set": "3/3/94"
},
"CurrentHeatingCoolingState": {
},

"CurrentHeatingCoolingState": {
"Listen": "3/3/64"
}
},
{
"type": "WindowCovering",
"description": "iOS9 Window covering (blinds etc) type, still WIP",
"name": "Blinds",
"TargetPosition": {
"Set": "1/2/3",
}
},

{
"type": "WindowCovering",
"description": "iOS9 Window covering (blinds etc) type, still WIP",
"name": "Blinds",
"TargetPosition": {
"Set": "1/2/3",
"Listen": "1/2/4"
},
"CurrentPosition": {
"Set": "1/3/1",
},

"CurrentPosition": {
"Set": "1/3/1",
"Listen": "1/3/2"
},
"PositionState": {
},

"PositionState": {
"Listen": "2/7/1"
}
}
]
},
{
"description": "sample contact sensor device",
"name": "Office Contact",
"services": [
{
"type": "ContactSensor",
"name": "Office Door",
"ContactSensorState": {
}
}
]
},

{
"description": "sample contact sensor device",
"name": "Office Contact",
"services": [
{
"type": "ContactSensor",
"name": "Office Door",
"ContactSensorState": {
"Listen": "5/3/5"
}
}
]
},
{
"description": "sample garage door opener",
"name": "Office Garage",
"services": [
{
"type": "GarageDoorOpener",
"name": "Office Garage Opener",
"CurrentDoorState": {
}
}
]
},

{
"description": "sample garage door opener",
"name": "Office Garage",
"services": [
{
"type": "GarageDoorOpener",
"name": "Office Garage Opener",
"CurrentDoorState": {
"Listen": "5/4/5"
},
"TargetDoorState": {
},

"TargetDoorState": {
"Listen": "5/4/6"
}
}
]
}
]
}
],
"accessories": [
}
}
]
}
]
}
],

"accessories": [

]
}
]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ You need to configure all devices directly in the config.json. You can find a sa
"name": "KNX",
"knxd_ip": "192.168.1.1",
"knxd_port": 6720,
"knxd_do_not_read_set_groups":true,
"accessories": [
{
"name": "Living Room North Lamp",
Expand Down
27 changes: 20 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ New 2015-11-05:
New 2015-11-18:
- get rid of obsolete "knxdevice" accessory_type (there is only one anyhow!)
accessory_type is not required in config.json section platform KNX accessories any more.
New 2015-12-01
- new flag for 'knxd_do_not_read_set_groups' true or false:
when true neither READ requests are sent to the bus nor is listened to "SET" group addresses (you might duplicate them to "Listen":[] if required)
*
*/

Expand Down Expand Up @@ -82,6 +85,7 @@ KNXPlatform.prototype = {
// push knxd connection setting to each device from platform
foundAccessories[int].knxd_ip = this.config.knxd_ip;
foundAccessories[int].knxd_port = this.config.knxd_port;
foundAccessories[int].knxd_do_not_read_set_groups = this.config.knxd_do_not_read_set_groups; // new
//var accConstructor = require('./knxdevice.js');
var acc = new KNXDevice(this.log,foundAccessories[int]);
this.log("created "+acc.name+" accessory");
Expand Down Expand Up @@ -331,6 +335,7 @@ function KNXDevice(log, config) {
} else {
throw new Error("MISSING KNXD PORT");
}
this.knxd_do_not_read_set_groups = config.knxd_do_not_read_set_groups ? true:false; // convert trueish to true

}

Expand Down Expand Up @@ -736,6 +741,7 @@ KNXDevice.prototype = {
var myCharacteristic = myService.getCharacteristic(characteristicType);
var setGA = "";
var setReverse = false;
var listenaddresses;
if (myCharacteristic === undefined) {
throw new Error("unknown characteristics cannot be bound");
}
Expand Down Expand Up @@ -789,31 +795,38 @@ KNXDevice.prototype = {
}
}
}
if ([config.Set].concat(config.Listen || []).length>0) {
if (this.knxd_do_not_read_set_groups) {
listenaddresses = config.Listen || []; // listen to LISTEN addresses only;

} else {
listenaddresses = [config.Set].concat(config.Listen || []); // listen to all, even SET addresses

}
if (listenaddresses.length>0) {
//this.log("Binding LISTEN");
// can read
switch (valueType) {
case "Bool":
this.knxregister_bool([config.Set].concat(config.Listen || []), myCharacteristic);
this.knxregister_bool(listenaddresses, myCharacteristic);
break;
case "Percent":
this.knxregister_percent([config.Set].concat(config.Listen || []), myCharacteristic);
this.knxregister_percent(listenaddresses, myCharacteristic);
break;
case "Float":
this.knxregister_float([config.Set].concat(config.Listen || []), myCharacteristic);
this.knxregister_float(listenaddresses, myCharacteristic);
break;
case "Int":
this.knxregister_int([config.Set].concat(config.Listen || []), myCharacteristic);
this.knxregister_int(listenaddresses, myCharacteristic);
break;
case "HVAC":
this.knxregister_HVAC([config.Set].concat(config.Listen || []), myCharacteristic);
this.knxregister_HVAC(listenaddresses, myCharacteristic);
break;
default:
this.log(colorOn+ "[ERROR] unknown type passed: ["+valueType+"]"+colorOff);
throw new Error("[ERROR] unknown type passed");
}
this.log("["+ this.name +"]:["+myCharacteristic.displayName+"]: Issuing read requests on the KNX bus...");
this.knxreadarray([config.Set].concat(config.Listen || []));
this.knxreadarray(listenaddresses);
}
return myCharacteristic; // for chaining or whatsoever
},
Expand Down
Loading

0 comments on commit 9f59e92

Please sign in to comment.