Air Purifier
UUID: 000000BB-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 "Air Purifier" Homebridge plugin. Note
// Example Air Purifier Plugin module.exports = (api) => { api.registerAccessory('ExampleAirPurifierPlugin', ExampleAirPurifierAccessory); }; class ExampleAirPurifierAccessory { 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 Air Purifier service this.service = new this.Service(this.Service.AirPurifier); // create handlers for required characteristics this.service.getCharacteristic(this.Characteristic.Active) .on('get', this.handleActiveGet.bind(this)) .on('set', this.handleActiveSet.bind(this)); this.service.getCharacteristic(this.Characteristic.CurrentAirPurifierState) .on('get', this.handleCurrentAirPurifierStateGet.bind(this)); this.service.getCharacteristic(this.Characteristic.TargetAirPurifierState) .on('get', this.handleTargetAirPurifierStateGet.bind(this)) .on('set', this.handleTargetAirPurifierStateSet.bind(this)); } /** * 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); } /** * Handle requests to get the current value of the "Current Air Purifier State" characteristic */ handleCurrentAirPurifierStateGet(callback) { this.log.debug('Triggered GET CurrentAirPurifierState'); // set this to a valid value for CurrentAirPurifierState const currentValue = 1; callback(null, currentValue); } /** * Handle requests to get the current value of the "Target Air Purifier State" characteristic */ handleTargetAirPurifierStateGet(callback) { this.log.debug('Triggered GET TargetAirPurifierState'); // set this to a valid value for TargetAirPurifierState const currentValue = 1; callback(null, currentValue); } /** * Handle requests to set the "Target Air Purifier State" characteristic */ handleTargetAirPurifierStateSet(value, callback) { this.log.debug('Triggered SET TargetAirPurifierState:' value); callback(null); } }