Skip to content

Commit

Permalink
Merge pull request #11 from athombv/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
KyleAthom authored May 20, 2020
2 parents 2fd9762 + 124fa50 commit c542e87
Show file tree
Hide file tree
Showing 1,696 changed files with 65,849 additions and 40,789 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "athom"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"1.1.2": {
"en": "Improve KNX connection stability.",
"nl": "Verbeterde stabiliteit van de KNX verbinding."
},
"1.1.1": {
"en": "Add support for electric power measurement devices.",
"nl": "Voegt ondersteuning toe voor elektrische verbruikmeters."
},
"1.1.0": {
"en": "Connection to KNX network improvements and small protocol fixes.",
"nl": "Betere verbinding naar het KNX netwerk en vele kleine verbeteringen."
}
}
27 changes: 27 additions & 0 deletions .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"id": "org.knx",
"version": "1.1.2",
"compatibility": ">=3.0.0",
"sdk": 2,
"brandColor": "#006BB3",
"name": {
"en": "KNX",
"nl": "KNX"
},
"description": {
"en": "Adds support for devices using the KNX network.",
"nl": "Voegt ondersteuning toe voor apparaten op een KNX-netwerk"
},
"category": [
"appliances"
],
"permissions": [],
"images": {
"large": "/assets/images/large.png",
"small": "/assets/images/small.png"
},
"author": {
"name": "Athom B.V.",
"email": "[email protected]"
}
}
1 change: 1 addition & 0 deletions .homeycompose/drivers/pair/parse_knxproj/assets/deflate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/*
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
Expand Down
1 change: 1 addition & 0 deletions .homeycompose/drivers/pair/parse_knxproj/assets/inflate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/*
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/*
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/* jshint worker:true */
(function main(global) {
"use strict";
Expand Down
1 change: 1 addition & 0 deletions .homeycompose/drivers/pair/parse_knxproj/assets/zip-ext.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/*
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
Expand Down
1 change: 1 addition & 0 deletions .homeycompose/drivers/pair/parse_knxproj/assets/zip-fs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/*
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
Expand Down
1 change: 1 addition & 0 deletions .homeycompose/drivers/pair/parse_knxproj/assets/zip.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/*
Copyright (c) 2013 Gildas Lormeau. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/drivers/pair/parse_knxproj/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<fieldset>
<legend>Upload project</legend>
<div class="field row">
<input id="file-input" accept="application/knxproj" type="file"/>
<input id="file-input" type="file"/>
</div>
</fieldset>
</div>
Expand Down
20 changes: 3 additions & 17 deletions .homeycompose/drivers/pair/select_interface/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1 data-i18n="settings.ip.title">
interfaceList.push({name: Homey.__('settings.ip.manual_interface'), mac:'000000000000', ip: Homey.__('settings.ip.manual_interface_input')});
renderKNXInterfaceList(interfaceList);
} else if (error) {
Homey.alert(error);
Homey.alert(error.message);
}
});

Expand All @@ -75,12 +75,7 @@ <h1 data-i18n="settings.ip.title">
interfaceList.push({name: Homey.__('settings.ip.manual_interface'), mac:'000000000000', ip: Homey.__('settings.ip.manual_interface_input')});
renderKNXInterfaceList(interfaceList);
} else if (error) {
switch(error) {
case 'search_already_running':
Homey.alert(Homey.__("errors.ip.search_already_running")); break;
default:
Homey.alert((Homey.__("errors.generic_error") + error)); break;
}
return Homey.alert(error.message);
}
});
});
Expand All @@ -92,16 +87,7 @@ <h1 data-i18n="settings.ip.title">
if(interfaceList) {
renderKNXInterfaceList(interfaceList);
} else if (error) {
switch(error) {
case 'invalid_ip':
Homey.alert(Homey.__("errors.ip.invalid_ip")); break;
case 'interface_not_found':
Homey.alert(Homey.__("errors.ip.interface_not_found")); break;
case 'search_already_running':
Homey.alert(Homey.__("errors.ip.search_already_running")); break;
default:
Homey.alert((Homey.__("errors.generic_error") + error)); break;
}
Homey.alert(error.message);
}
});
});
Expand Down
3 changes: 2 additions & 1 deletion .homeyignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.psd
*.psd
test/
86 changes: 86 additions & 0 deletions README-KNX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# KNX Documentation

## Introduction
KNX is a home automation standard and protocol mostly used in larger buildings such as offices or villa's.
It's primary physical connection is a 9600baud serial bus, but IP and RF connections are part of the standard.
The network parameters as well of the parameters of the devices in the network can be programmed with ETS, the official KNX engineering software.

## Devices
To couple physical devices on the network, KNX uses topology addresses to communicate with devices and functions. Topology addresses are bound to a single physical device, like an IP address in networking.
For example, a small demo network might look like this:

Topology example:
- USB interface 1.1.0
- KNX/IP interface 1.1.1
- Dimming actor 1.1.2
- Button actor 1.1.3

Usually the first digit is used to indicate the building or building segment, the second digit is for the KNX line (segment) and the third digit is the unique physical device.
The lowest assignable address is 1.1.0, the highest assignable address is 15.15.255.
Most (but not all!) KNX devices will fallback to 15.15.255 when they are not configured.
Further knowledge about topology addresses is not needed to combine KNX with Homey and will therefore be left out of this document.

## Functionality
Physical devices won't do anything until there are group addresses assingned to their functions.
Group addresses represent objects which contains functionality or information. Group addresses can be bound to functionality of a device or group of devices, but can also be provided by the network itself.

Group addresses example:
- 1/1/0 Lamp switching
- 2/1/0 Lamp dimming
- 8/1/0 Lamp switch status
- 8/2/0 Lamp dim status

To switch the light connected on actor 1.1.0 with a button on actor 1.1.1, the switching functionality for both actors has to be coupled to groupaddress 1/1/0 in ETS.
The same goes for the dimming functionality. Bind the dimming actor output and the longpress dimming input into group address 2/1/0 and the light will be dimmable through the button actor.

Usually group addresses are grouped by function or location. For example, all switching goes into 1/x/y, dimming into 2/a/b etc.
You can then divide the main groups into the location, eg. 1/1/y are the switching the living room, 1/2/z is switching for the hallway etc.

More information on how to bind functionality on group addresses can be found in this video: https://www.youtube.com/watch?v=2TGaroLM_HE

## Datapoints
Just like types in programming languages there are different datapoints within the KNX standard to implement the data embedded in the KNX packets.
The datapoint types and their implementation are listed on: https://support.knx.org/hc/en-us/articles/115001133744

## Controlling devices with Homey
The KNX app for Homey uses the knx javascript library located over here: https://www.npmjs.com/package/knx
This library allows for a quick setup and handles all communication, group addresses, building KNX telegrams etc.
On top off the library functions are added for the following actions:
- Scan the LAN for KNX IP interfaces
- Manage found IP Interfaces
- Map/pair Homey device functionality to KNX groupaddreses
- Convert and store an KNX export into the app storage

To control devices with Homey, you"ll need and three pieces of information: The data you want to send, the datatype and the groupaddress to send the data to.
You can then write a telegram through the KNX libray, which will take care of creating and sending the telegram through the KNX network.

## Connection to KNX
In the test setup in our office, we have three different ways to connect to the KNX network:
- Hager USB interface
- Hager KNX/IP Router
- Weinzierl KNX/IP interface (this is our only supported interface)

Both KNX/IP units work in a similiar fashion, with the difference that the router supports multiple KNX networks, as well as IP multicast connections.
The interface only supports a tunnel connection to the KNX network, whichs means that only a single client can connect to it. Some IP interfaces like our Weinzierl supports more slots to enable concurrent tunnel connections.
Routers do not have this limitations as you can send the traffic to a IP multicast address (224.0.23.12) which will be then routed into the KNX network.

When programming physical KNX devices for the first time it's advised to use the USB interface. This ensures a reliable connection when uploading the application firmware.

## ETS
ETS (Engineering Tool Software) is the software that is provided by the KNX organization to setup and maintain a KNX installation. It's the only way to do so.
It's used to assign addresses to the physical devices, configure them and enable there functionality by attaching groupaddresses to their functions.
This software runs only under Windows. It's only obtainable with a KNX license, but you might have some luck over here: https://www.roelbroersma.nl/forums/topic/ets-5-7-4/.
Whenever using an ETS version that is not obtained officialy from knx.org, make sure to never ever send a project back to a customer.
The original version checks for a fingerprint in the project file which disables opening files altered with non-original versions.
It's advised to run those ETS version inside a virtual machine and to create a snapshot before upgrading to a new version since it might crash/become corrupted.

## Maintenance
The KNX library is updated aprox. every two months. It's advised as it's still being improved. In the past, these updates never broke our implementation so they are considered 'safe'.

## Future improvements
- Instead of parsing the datapoints itself, use this library: https://github.com/Rafelder/knx-datapoints
- Implement traffic through multicast if a KNX router is detected. This can improve (network) stability and has the advantage of not having to select an IP interface on pairing.

## Useful information
Roel Broersma Gira Homeserver forum: https://www.roelbroersma.nl/forums/forum/gira-homeserver/
Joachim Goeminne KNX playlist: https://www.youtube.com/watch?v=GxZA1M6JeJ8&list=PLzpMAP5eF_wRp_sxg3pGPO_j-DoemkcsH&index=1
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# KNX

Add your KNX devices to Homey. This app requires a KNX IP Router or Interface connected to the same Wi-Fi network as Homey.
Add your KNX devices to Homey. This app requires a KNX IP Router or Interface connected to the same Wi-Fi network as Homey. Please make sure that either Homey is the only KNX/IP device in your network or that your IP interface can handle multiple simultaneous connections.

## Changelog

### v1.0.15
Bugfixes and crash preventions.

### v1.0.13
Added automatic re-detection of KNX interfaces. This should re-find the used KNX interface if it's IP has changed over time.

### v1.0.12
Small bugfixes and error handling.

### v1.0.11
KNX Connection improvements.

## Supported KNX devices

Expand Down Expand Up @@ -37,17 +51,13 @@ Device within Homey which triggers a KNX scene to become active.
To set-up your KNX network in Homey, this app provides three options.

### Learn mode

For switch devices, Homey listens for a press on a button and copies the KNX Group Address (e.g. 0/1/2).

### ETS Import

If there is an ETS (.knxproj-file) export available, it can be uploaded to Homey to make it easier to assign KNX Group Addresses to a Homey device. Most likely your installer can provide this file for you.

### Manual entry

It is possible to manually enter KNX Group Addresses during set-up (e.g. 0/1/2). These values can usually be found in a 'group address export' (.esf-file). Most likely your installer can provide this file for you.

## Support

KNX Networks might be complicated to set-up. Please contact your local KNX Installer if you require any assistance.
1 change: 1 addition & 0 deletions README.nl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Breid de mogelijkheden van je KNX netwerk uit met alle apparaten welke je toegevoegd hebt aan Homey. Bestuur je draadloze lampen via KNX of bestuur je KNX apparaten met een draadloze sensor.
1 change: 1 addition & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Expand the capabilities of your exisiting KNX network with all the devices you've added to Homey. Now you can control wireless lights through KNX, or control KNX devices through a wireless sensor.
22 changes: 14 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ class KNXApp extends Homey.App {

onInit() {
this.log('KNXApp is running...');
this.knxInterfaceManager = new KNXInterfaceManager();
this.knxInterfaceManager.on('interface_found', (knxInterface) => {
this.emit('interface_found', knxInterface);
this.emit('interface_found' + knxInterface.macAddress, knxInterface);
});
this.knxInterfaceManager.on('no_interfaces', () => {
this.emit('no_interfaces');
});

Homey.ManagerCloud.getLocalAddress()
.then((address) => {
const homeyIP = address.split(':', 1).toString();
this.log('Homey IP + Parsed IP', address, homeyIP);
this.knxInterfaceManager = new KNXInterfaceManager(homeyIP);
this.knxInterfaceManager.on('interface_found', (knxInterface) => {
this.emit('interface_found', knxInterface);
this.emit('interface_found' + knxInterface.macAddress, knxInterface);
});
this.knxInterfaceManager.on('no_interfaces', () => {
this.emit('no_interfaces');
});
})
}

// Ask the interfacemanager if there's a known IP interface with the corresponding MAC address.
Expand Down
Loading

0 comments on commit c542e87

Please sign in to comment.