Valve
UUID: 000000D0-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 "Valve" Homebridge plugin. Note
// Example Valve Plugin module.exports = (api) => { api.registerAccessory('ExampleValvePlugin', ExampleValveAccessory); }; class ExampleValveAccessory { 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 Valve service this.service = new this.Service(this.Service.Valve); // 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.InUse) .on('get', this.handleInUseGet.bind(this)); this.service.getCharacteristic(this.Characteristic.ValveType) .on('get', this.handleValveTypeGet.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 "In Use" characteristic */ handleInUseGet(callback) { this.log.debug('Triggered GET InUse'); // set this to a valid value for InUse const currentValue = 1; callback(null, currentValue); } /** * Handle requests to get the current value of the "Valve Type" characteristic */ handleValveTypeGet(callback) { this.log.debug('Triggered GET ValveType'); // set this to a valid value for ValveType const currentValue = 1; callback(null, currentValue); } }