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

Remote Addins #161

Closed Luehrsen closed 4 years ago

Luehrsen commented 4 years ago

This PR adds the ability for addins to be located outside of the NPM package. That makes the addins more versatile and custom behaviour is easier to realise.

These are the main changes of this PR:

1) Load addins from the knx_addins folder in the homebridge config folder

When an accessory loads a Handler the customServiceApi first looks into the local addins folder. If an appropriate Handler-file is found there, that is being loaded. If not, it looks in the knx_addins folder in the homebridge config folder.

2) Provide a localised require named knxRequire

In order for external modules to be treated as internally, for loading modules etc., we had to wrap a require function and register that globally.

The only notable change for external addins from the current paradigma would be the name of the require function for handlerpattern and debug.

var HandlerPattern = knxRequire( './lib/addins/handlerpattern.js' );
var log = knxRequire('debug')('GiraThermostatServo3Handler');

fixes #160