Package Exports
- homebridge-lib
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (homebridge-lib) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
homebridge-lib
Utility Library for Homebridge Plugins
Copyright © 2017,2018 Erik Baauw. All rights reserved.
While developing a number of Homebridge plugins, I find myself duplicating a lot of code. The idea behind this utility library is to ease developing and maintaining Homebridge plugins by separating this generic code, dealing with HomeKit and Homebridge, from the specific code, dealing with the actual devices being exposed to HomeKit.
The homebridge-lib library provides the following functionality:
- Saving and restoring accessories from persistent storage between Homebridge sessions (using the homebridge v2 dynamic platform model);
- History for Eve;
- Universal Plug & Play (UPnP) device discovery;
- Setting up a heartbeat for device polling;
- Logging and error handling;
- Defining custom HomeKit services and characteristics;
- Checking the NodeJS and Homebridge versions used;
- Checking the latest plugin version published to the NPM registry;
- Utility functions for: JSON formatting, calling a REST API, parsing
config.json.
Technically, the homebridge-lib library is based on the following:
- Using asynchronous functions rather than callback functions;
- Using javascript classes rather than prototypes. An actual plugin extends the classes provided by
homebridge-lib; - Using events. In fact all
homebridge-libclasses extendEventEmitter;
The homebridge-lib library provides a number of abstract superclasses, that act as delegate for HomeKit accessories, services, and characteristics. A Homebridge plugin based on homebridge-lib extends these classes, providing the device-specific logic.
See the Wiki for more information. See homebridge-ws as an example plugin based on homebridge-lib.
Installation
This library is not a Homebridge plugin and should not be installed manually. Instead, Homebridge plugins using this library should list it as a dependency in their package.json. This way, npm installs homebridge-lib automatically when installing the actual plugin.
Credits
The logic for handling Eve history was copied from Simone Tisa's fakegato-history repository, copyright © 2017 simont77.