const Base = require('./base');
class Monitor extends Base {
  constructor(mijia) {
    super(mijia);
  }
  parseMsg(msg, rinfo) {
    
  }
}
@@ -25,16 +25,84 @@
 base');%0A
+let PlatformAccessory, Accessory, Service, Characteristic, UUIDGen;%0A
 class Mo
@@ -169,41 +169,2076 @@
 ;%0A  
-%7D%0A  parseMsg(msg, rinfo) %7B%0A    %0A  %7D%0A%7D
+  PlatformAccessory = mijia.PlatformAccessory;%0A    Accessory = mijia.Accessory;%0A    Service = mijia.Service;%0A    Characteristic = mijia.Characteristic;%0A    UUIDGen = mijia.UUIDGen;%0A  %7D%0A  /**%0A * parse the gateway json msg%0A * @param %7B*json%7D json %0A * @param %7B*remoteinfo%7D rinfo %0A */%0A  parseMsg(json, rinfo) %7B%0A    let %7B cmd, model, sid %7D = json;%0A    let data = JSON.parse(json.data);%0A    let %7B voltage, status %7D = data;%0A    this.mijia.log.debug(%60$%7Bmodel%7D $%7Bcmd%7D voltage-%3E$%7Bvoltage%7D status-%3E$%7Bstatus%7D%60);%0A    this.setMotionSensor(sid, voltage, temperature)%0A  %7D%0A  /**%0A   * set up MotionSensor(mijia motion sensor)%0A   * @param %7B*device id%7D sid %0A   * @param %7B*device voltage%7D voltage %0A   * @param %7B*device status%7D status %0A   */%0A  setMotionSensor(sid, voltage, status) %7B%0A    let uuid = UUIDGen.generate('Mijia-MotionSensor@' + sid);%0A    let accessory = this.mijia.accessories%5Buuid%5D;%0A    let service;%0A    if (!accessory) %7B%0A      //init a new homekit accessory%0A      let name = sid.substring(sid.length - 4);%0A      accessory = new PlatformAccessory(name, uuid, Accessory.Categories.SENSOR);%0A      accessory.getService(Service.AccessoryInformation)%0A        .setCharacteristic(Characteristic.Manufacturer, %22Mijia%22)%0A        .setCharacteristic(Characteristic.Model, %22Mijia MotionSensor%22)%0A        .setCharacteristic(Characteristic.SerialNumber, sid);%0A      accessory.on('identify', function (paired, callback) %7B%0A        callback();%0A      %7D);%0A      service = new Service.MotionSensor(name);%0A      accessory.addService(service, name);%0A      accessory.addService(new Service.BatteryService(name), name);%0A    %7D else %7B%0A      service = accessory.getService(Service.MotionSensor);%0A    %7D%0A    accessory.reachable = true;%0A    if (status != undefined) %7B%0A      service.getCharacteristic(Characteristic.MotionDetected).updateValue('motion' == status);%0A    %7D%0A    this.setBatteryService(sid, voltage, accessory);%0A    if (!this.mijia.accessories%5Buuid%5D) %7B%0A      this.mijia.accessories%5Buuid%5D = accessory;%0A      this.registerAccessory(%5Baccessory%5D);%0A    %7D%0A    return accessory;%0A  %7D%0A%7D%0Amodule.exports = Monitor;

add mijia monitor support