Time Information

UUID: 00000099-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 "Time Information" Homebridge plugin.
// Example Time Information Plugin

module.exports = (api) => {
  api.registerAccessory('ExampleTimeInformationPlugin', ExampleTimeInformationAccessory);
};

class ExampleTimeInformationAccessory {

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

      // create handlers for required characteristics
      this.service.getCharacteristic(this.Characteristic.CurrentTime)
        .on('get', this.handleCurrentTimeGet.bind(this))
        .on('set', this.handleCurrentTimeSet.bind(this));

      this.service.getCharacteristic(this.Characteristic.DayoftheWeek)
        .on('get', this.handleDayoftheWeekGet.bind(this))
        .on('set', this.handleDayoftheWeekSet.bind(this));

      this.service.getCharacteristic(this.Characteristic.TimeUpdate)
        .on('get', this.handleTimeUpdateGet.bind(this));

  }

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

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

    callback(null, currentValue);
  }

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

    callback(null);
  }

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

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

    callback(null, currentValue);
  }

  /**
   * Handle requests to set the "Day of the Week" characteristic
   */
  handleDayoftheWeekSet(value, callback) {
    this.log.debug('Triggered SET DayoftheWeek:' value);

    callback(null);
  }

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

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

    callback(null, currentValue);
  }


}