Microphone

UUID: 00000112-0000-1000-8000-0026BB765291

Required Characteristics

Optional Characteristics

Example

Note

The example below is automatically generated and may not be a complete example of what is required to create a working "Microphone" Homebridge plugin.
// Example Microphone Plugin

module.exports = (api) => {
  api.registerAccessory('ExampleMicrophonePlugin', ExampleMicrophoneAccessory);
};

class ExampleMicrophoneAccessory {

  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 Microphone service
      this.service = new this.Service(this.Service.Microphone);

      // create handlers for required characteristics
      this.service.getCharacteristic(this.Characteristic.Mute)
        .on('get', this.handleMuteGet.bind(this))
        .on('set', this.handleMuteSet.bind(this));

  }

  /**
   * Handle requests to get the current value of the "Mute" characteristic
   */
  handleMuteGet(callback) {
    this.log.debug('Triggered GET Mute');

    // set this to a valid value for Mute
    const currentValue = 1;

    callback(null, currentValue);
  }

  /**
   * Handle requests to set the "Mute" characteristic
   */
  handleMuteSet(value, callback) {
    this.log.debug('Triggered SET Mute:' value);

    callback(null);
  }

}