Input Source

UUID: 000000D9-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 "Input Source" Homebridge plugin.
// Example Input Source Plugin

module.exports = (api) => {
  api.registerAccessory('ExampleInputSourcePlugin', ExampleInputSourceAccessory);
};

class ExampleInputSourceAccessory {

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

      // create handlers for required characteristics
      this.service.getCharacteristic(this.Characteristic.ConfiguredName)
        .on('get', this.handleConfiguredNameGet.bind(this))
        .on('set', this.handleConfiguredNameSet.bind(this));

      this.service.getCharacteristic(this.Characteristic.InputSourceType)
        .on('get', this.handleInputSourceTypeGet.bind(this));

      this.service.getCharacteristic(this.Characteristic.IsConfigured)
        .on('get', this.handleIsConfiguredGet.bind(this))
        .on('set', this.handleIsConfiguredSet.bind(this));

      this.service.getCharacteristic(this.Characteristic.Name)
        .on('get', this.handleNameGet.bind(this));

      this.service.getCharacteristic(this.Characteristic.CurrentVisibilityState)
        .on('get', this.handleCurrentVisibilityStateGet.bind(this));

  }

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

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

    callback(null, currentValue);
  }

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

    callback(null);
  }

  /**
   * Handle requests to get the current value of the "Input Source Type" characteristic
   */
  handleInputSourceTypeGet(callback) {
    this.log.debug('Triggered GET InputSourceType');

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

    callback(null, currentValue);
  }


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

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

    callback(null, currentValue);
  }

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

    callback(null);
  }

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

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

    callback(null, currentValue);
  }


  /**
   * Handle requests to get the current value of the "Current Visibility State" characteristic
   */
  handleCurrentVisibilityStateGet(callback) {
    this.log.debug('Triggered GET CurrentVisibilityState');

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

    callback(null, currentValue);
  }


}