Stateful Programmable Switch
UUID: 00000088-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 "Stateful Programmable Switch" Homebridge plugin. Note
// Example Stateful Programmable Switch Plugin module.exports = (api) => { api.registerAccessory('ExampleStatefulProgrammableSwitchPlugin', ExampleStatefulProgrammableSwitchAccessory); }; class ExampleStatefulProgrammableSwitchAccessory { 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 Stateful Programmable Switch service this.service = new this.Service(this.Service.StatefulProgrammableSwitch); // create handlers for required characteristics this.service.getCharacteristic(this.Characteristic.ProgrammableSwitchEvent) .on('get', this.handleProgrammableSwitchEventGet.bind(this)); this.service.getCharacteristic(this.Characteristic.ProgrammableSwitchOutputState) .on('get', this.handleProgrammableSwitchOutputStateGet.bind(this)) .on('set', this.handleProgrammableSwitchOutputStateSet.bind(this)); } /** * Handle requests to get the current value of the "Programmable Switch Event" characteristic */ handleProgrammableSwitchEventGet(callback) { this.log.debug('Triggered GET ProgrammableSwitchEvent'); // set this to a valid value for ProgrammableSwitchEvent const currentValue = 1; callback(null, currentValue); } /** * Handle requests to get the current value of the "Programmable Switch Output State" characteristic */ handleProgrammableSwitchOutputStateGet(callback) { this.log.debug('Triggered GET ProgrammableSwitchOutputState'); // set this to a valid value for ProgrammableSwitchOutputState const currentValue = 1; callback(null, currentValue); } /** * Handle requests to set the "Programmable Switch Output State" characteristic */ handleProgrammableSwitchOutputStateSet(value, callback) { this.log.debug('Triggered SET ProgrammableSwitchOutputState:' value); callback(null); } }