snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 56 forks source link

Creating Complex Handlers #74

Closed ND00 closed 7 years ago

ND00 commented 7 years ago

Hi,

I'm trying to do the following task and I was wondering if it is possible to do that using a homebridge-knx plugin

  1. A physical KNX switch is sending some telegram to a virtual address group (x/y/z).
  2. A handler will listen to this address (x/y/z) and once it gets the call, it will send several telegrams to few group address (not related to the Characteristic that was used in the knx_config.json to register the handler)

I'm trying to use the handles framework in order to program the behavior of physical switches. So they can be used to perform complex scenes.

If possible, could you please indicate what needs to be done (handler / config) to achieve this?

Thanks ND

snowdd1 commented 7 years ago

Of course you can. Though I am not convinced you should. homebridge-knx is meant as a front end support for HomeKit, not as a replacement for a homeserver (like GIRA's e.g., or of any other make).

However, if you want to continue anyhow:

You'll need to use a Switch or Lightbulb service, with an handler that uses the LocalConstants section in the knx_config.json to store the addresses (and probably the values) of the group addresses to be changed upon. LocalConstants are used in the handler code by the function getLocalConstant(). As the contants are transportet as-is, you can put any content in it you can store in a JSON structure. The handler simply needs to de-compose it.

To react to a bus value change, you need to have an active characteristic, such as the On characteristic of a switch, or -alternatively- an KNXObjects entry; both must have a Listen group group address assigned, so that they get bound to the bus events.

To write any value to the bus, you need to use the knxWrite() function. The addresses, DPT, and values can either be stored in your handler's code, or can be taken from the knx_config.json using the above-mentioned LocalConstants.

I definitely recommend reading the documentation and understanding the Sample first!

Good luck!

ND00 commented 7 years ago

Thanks