Target Control
UUID: 00000125-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 "Target Control" Homebridge plugin. Note
// Example Target Control Plugin module.exports = (api) => { api.registerAccessory('ExampleTargetControlPlugin', ExampleTargetControlAccessory); }; class ExampleTargetControlAccessory { 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 Target Control service this.service = new this.Service(this.Service.TargetControl); // create handlers for required characteristics this.service.getCharacteristic(this.Characteristic.ActiveIdentifier) .on('get', this.handleActiveIdentifierGet.bind(this)) .on('set', this.handleActiveIdentifierSet.bind(this)); this.service.getCharacteristic(this.Characteristic.Active) .on('get', this.handleActiveGet.bind(this)) .on('set', this.handleActiveSet.bind(this)); } /** * Handle requests to get the current value of the "Active Identifier" characteristic */ handleActiveIdentifierGet(callback) { this.log.debug('Triggered GET ActiveIdentifier'); // set this to a valid value for ActiveIdentifier const currentValue = 1; callback(null, currentValue); } /** * Handle requests to set the "Active Identifier" characteristic */ handleActiveIdentifierSet(value, callback) { this.log.debug('Triggered SET ActiveIdentifier:' value); callback(null); } /** * Handle requests to get the current value of the "Active" characteristic */ handleActiveGet(callback) { this.log.debug('Triggered GET Active'); // set this to a valid value for Active const currentValue = 1; callback(null, currentValue); } /** * Handle requests to set the "Active" characteristic */ handleActiveSet(value, callback) { this.log.debug('Triggered SET Active:' value); callback(null); } }