Outlet
UUID: 00000047-0000-1000-8000-0026BB765291
Required Characteristics
Optional Characteristics
Example
The example below is automatically generated and may not be a complete example of what is required to create a working "Outlet" Homebridge plugin. Note
// Example Outlet Plugin module.exports = (api) => { api.registerAccessory('ExampleOutletPlugin', ExampleOutletAccessory); }; class ExampleOutletAccessory { constructor(log, config, api) { this.log = log; this.config = config; this.api = api; this.Service = this.api.hap.Service; this.Characteristic = this.api.hap.Characteristic; // extract name from config this.name = config.name; // create a new Outlet service this.service = new this.Service(this.Service.Outlet); // create handlers for required characteristics this.service.getCharacteristic(this.Characteristic.On) .on('get', this.handleOnGet.bind(this)) .on('set', this.handleOnSet.bind(this)); this.service.getCharacteristic(this.Characteristic.OutletInUse) .on('get', this.handleOutletInUseGet.bind(this)); } /** * Handle requests to get the current value of the "On" characteristic */ handleOnGet(callback) { this.log.debug('Triggered GET On'); // set this to a valid value for On const currentValue = 1; callback(null, currentValue); } /** * Handle requests to set the "On" characteristic */ handleOnSet(value, callback) { this.log.debug('Triggered SET On:' value); callback(null); } /** * Handle requests to get the current value of the "Outlet In Use" characteristic */ handleOutletInUseGet(callback) { this.log.debug('Triggered GET OutletInUse'); // set this to a valid value for OutletInUse const currentValue = 1; callback(null, currentValue); } }