Humidifier Dehumidifier

UUID: 000000BD-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 "Humidifier Dehumidifier" Homebridge plugin.
// Example Humidifier Dehumidifier Plugin

module.exports = (api) => {
  api.registerAccessory('ExampleHumidifierDehumidifierPlugin', ExampleHumidifierDehumidifierAccessory);
};

class ExampleHumidifierDehumidifierAccessory {

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

      // create handlers for required characteristics
      this.service.getCharacteristic(this.Characteristic.CurrentRelativeHumidity)
        .on('get', this.handleCurrentRelativeHumidityGet.bind(this));

      this.service.getCharacteristic(this.Characteristic.CurrentHumidifierDehumidifierState)
        .on('get', this.handleCurrentHumidifierDehumidifierStateGet.bind(this));

      this.service.getCharacteristic(this.Characteristic.TargetHumidifierDehumidifierState)
        .on('get', this.handleTargetHumidifierDehumidifierStateGet.bind(this))
        .on('set', this.handleTargetHumidifierDehumidifierStateSet.bind(this));

      this.service.getCharacteristic(this.Characteristic.Active)
        .on('get', this.handleActiveGet.bind(this))
        .on('set', this.handleActiveSet.bind(this));

  }

  /**
   * Handle requests to get the current value of the "Current Relative Humidity" characteristic
   */
  handleCurrentRelativeHumidityGet(callback) {
    this.log.debug('Triggered GET CurrentRelativeHumidity');

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

    callback(null, currentValue);
  }


  /**
   * Handle requests to get the current value of the "Current Humidifier Dehumidifier State" characteristic
   */
  handleCurrentHumidifierDehumidifierStateGet(callback) {
    this.log.debug('Triggered GET CurrentHumidifierDehumidifierState');

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

    callback(null, currentValue);
  }


  /**
   * Handle requests to get the current value of the "Target Humidifier Dehumidifier State" characteristic
   */
  handleTargetHumidifierDehumidifierStateGet(callback) {
    this.log.debug('Triggered GET TargetHumidifierDehumidifierState');

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

    callback(null, currentValue);
  }

  /**
   * Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
   */
  handleTargetHumidifierDehumidifierStateSet(value, callback) {
    this.log.debug('Triggered SET TargetHumidifierDehumidifierState:' value);

    callback(null);
  }

  /**
   * 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);
  }

}