ebaauw / homebridge-lib

Utility Library for Homebridge Plugins
Apache License 2.0
94 stars 12 forks source link

How do I create my own Service using homebridge-lib? #7

Closed ctschach closed 6 years ago

ctschach commented 6 years ago

I only want to create one additional service inside my application, so I'm trying something like this:

var myService = new homebridgeLib.CustomHomeKitTypes(API, API.hap);

myService.createService('my.PowerMeter2', '00000012-0000-1000-8000-656261617577', [
  eve.Characteristic.ElectricCurrent,
  eve.Characteristic.CurrentConsumption
]);

This is causing an error, so I'm doing it wrong.

Is there any way to call "createService"?

ebaauw commented 6 years ago

Create a subclass of CustomHomeKitTypes in which you define your characteristics (and services), see https://github.com/ebaauw/homebridge-lib/blob/master/lib/MyHomeKitTypes.js. To use the characteristics, instantiate your subclass, see e.g. https://github.com/ebaauw/homebridge-hue/blob/f0a606e5c1041cd8244437780d2910661c79e6f3/lib/HuePlatform.js#L73-L79

ctschach commented 6 years ago

Yes, thanks...this helps....was able to integrate this.

Some documentation on how to use the various elements of homebridge-lib could not be wrong :-)

ebaauw commented 6 years ago

No, it wouldn’t. Note, however, that homebridge-lib is still in pre-release. First I want to refactor my plugins to use homebridge-lib in full, then publish a full releae version of homebridge-lib, then work on the WiKi. It’s all in my free time, and competing in priority with functional chnages to my plugins, so no ETA.