text: const HomeKit        = require('../../');
  const Accessory      = HomeKit.Accessory;
  const Service        = HomeKit.Service;
  const Characteristic = HomeKit.Characteristic;
  const uuid           = HomeKit.uuid;
  
  // here's a fake hardware device that we'll expose to HomeKit
  var FAKE_FAN = {
    powerOn: false,
    speed: 0,
    setPowerOn: function(on) {
      if(on){
        //put your code here to turn on the fan
        FAKE_FAN.powerOn = on;
      }
      else{
        //put your code here to turn off the fan
        FAKE_FAN.powerOn = on;
      }
    },
    setSpeed: function(value) {
      speed = value;
      console.log("Setting fan speed to %s", speed);
      //put your code here to set the fan to a specific value
    },
    identify: function() {
      //put your code here to identify the fan
      console.log('%s Identify!', fan.displayName);
    }
  }
  
  // This is the Accessory that we'll return to HAP-NodeJS that represents our fake fan.
  var fan = new Accessory('Fan', uuid.generate('homekit:accessories:Fan'));
  
  fan
  .getService(Service.AccessoryInformation)
  .setCharacteristic(Characteristic.Manufacturer, "Sample Company")
  
  // listen for the "identify" event for this Accessory
  fan.on('identify', function(paired, callback) {
    FAKE_FAN.identify();
    callback(); // success
  });
  
  // Add the actual Fan Service and listen for change events from iOS.
  // We can see the complete list of Services and Characteristics in `lib/gen/HomeKitTypes.js`
  fan
    .addService(Service.Fan, "Fan") // services exposed to the user should have "names" like "Fake Light" for us
    .getCharacteristic(Characteristic.On)
    .on('set', function(value, callback) {
      FAKE_FAN.setPowerOn(value);
      callback(); // Our fake Fan is synchronous - this value has been successfully set
    });
  
  // We want to intercept requests for our current power state so we can query the hardware itself instead of
  // allowing HAP-NodeJS to return the cached Characteristic.value.
  fan
    .getService(Service.Fan)
    .getCharacteristic(Characteristic.On)
    .on('get', function(callback) {
  
      // this event is emitted when you ask Siri directly whether your fan is on or not. you might query
      // the fan hardware itself to find this out, then call the callback. But if you take longer than a
      // few seconds to respond, Siri will give up.
  
      var err = null; // in case there were any problems
  
      if (FAKE_FAN.powerOn) {
        callback(err, true);
      }
      else {
        callback(err, false);
      }
    });
  
  // also add an "optional" Characteristic for spped
  fan
  .getService(Service.Fan)
  .addCharacteristic(Characteristic.RotationSpeed)
  .on('get', function(callback) {
    callback(null, FAKE_FAN.speed);
  })
  .on('set', function(value, callback) {
    FAKE_FAN.setSpeed(value);
    callback();
  })
  
  
  module.exports = fan;