<|start_filename|>config.schema.json<|end_filename|>
{
  "pluginAlias": "WyzeConnectedHome",
  "pluginType": "platform",
  "singular": true,
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Plugin Name",
        "description": "This name will appear in your Homebridge log",
        "type": "string",
        "default": "Wyze",
        "required": true
      },
      "username": {
        "title": "Username (E-Mail Address)",
        "description": "The e-mail address used for your Wyze account",
        "type": "string",
        "default": "",
        "required": true
      },
      "password": {
        "title": "Password",
        "description": "The password used for your Wyze account",
        "type": "string",
        "default": "",
        "required": true
      },
      "refreshInterval": {
        "title": "Refresh Interval",
        "description": "Specify the number of milliseconds to wait between updates, default is 10000 ms (10 seconds)",
        "type": "integer",
        "default": 10000,
        "required": false
      },
      "mfaCode": {
        "title": "One-time Password (for two-factor authentication)",
        "description": "Only required for initial login if you have two-factor authentication enabled on your Wyze account",
        "type": "string",
        "default": "",
        "required": false
      }
    }
  },
  "form": null,
  "display": null
}


<|start_filename|>src/accessories/WyzeContactSensor.js<|end_filename|>
const { Service, Characteristic } = require('../types');
const WyzeAccessory = require('./WyzeAccessory');

const HOMEBRIDGE_SERVICE = Service.ContactSensor;
const HOMEBRIDGE_CHARACTERISTIC = Characteristic.ContactSensorState;

module.exports = class WyzeContactSensor extends WyzeAccessory {
  constructor(plugin, homeKitAccessory) {
    super(plugin, homeKitAccessory);

    this.getOnCharacteristic();
  }

  getSensorService() {
    this.plugin.log.debug(`[ContactSensor] Retrieving previous service for "${this.display_name}"`);
    let service = this.homeKitAccessory.getService(HOMEBRIDGE_SERVICE);

    if (!service) {
      this.plugin.log.debug(`[ContactSensor] Adding service for "${this.display_name}"`);
      service = this.homeKitAccessory.addService(HOMEBRIDGE_SERVICE);
    }

    return service;
  }

  getOnCharacteristic() {
    this.plugin.log.debug(`[ContactSensor] Fetching status of "${this.display_name}"`);
    return this.getSensorService().getCharacteristic(HOMEBRIDGE_CHARACTERISTIC);
  }

  updateCharacteristics(device) {
    this.plugin.log.debug(`[ContactSensor] Updating status of "${this.display_name}"`);
    this.getOnCharacteristic().updateValue(device.device_params.open_close_state);
  }
};


<|start_filename|>src/accessories/WyzeMotionSensor.js<|end_filename|>
const { Service, Characteristic } = require('../types');
const WyzeAccessory = require('./WyzeAccessory');

const HOMEBRIDGE_SERVICE = Service.MotionSensor;
const HOMEBRIDGE_CHARACTERISTIC = Characteristic.MotionDetected;

module.exports = class WyzeMotionSensor extends WyzeAccessory {
  constructor(plugin, homeKitAccessory) {
    super(plugin, homeKitAccessory);

    this.getOnCharacteristic();
  }

  getSensorService() {
    this.plugin.log.debug(`[MotionSensor] Retrieving previous service for "${this.display_name}"`);
    let service = this.homeKitAccessory.getService(HOMEBRIDGE_SERVICE);

    if (!service) {
      this.plugin.log.debug(`[MotionSensor] Adding service for "${this.display_name}"`);
      service = this.homeKitAccessory.addService(HOMEBRIDGE_SERVICE);
    }

    return service;
  }

  getOnCharacteristic() {
    this.plugin.log.debug(`[MotionSensor] Fetching status of "${this.display_name}"`);
    return this.getSensorService().getCharacteristic(HOMEBRIDGE_CHARACTERISTIC);
  }

  updateCharacteristics(device) {
    this.plugin.log.debug(`[MotionSensor] Updating status of "${this.display_name}"`);
    this.getOnCharacteristic().updateValue(device.device_params.motion_state);
  }
};


<|start_filename|>src/types.js<|end_filename|>
const types = {};

module.exports = types;

module.exports.update = function (homebridge) {
  types.homebridge = homebridge;
  types.Accessory = homebridge.platformAccessory;
  types.Service = homebridge.hap.Service;
  types.Characteristic = homebridge.hap.Characteristic;
  types.UUIDGen = homebridge.hap.uuid;
};
