UNPKG

homebridge-miot

Version:

Homebridge plugin for devices supporting the miot protocol

68 lines (41 loc) 2.03 kB
const OutletDevice = require('../OutletDevice.js'); const Constants = require('../../../constants/Constants.js'); const PropFormat = require('../../../constants/PropFormat.js'); const PropUnit = require('../../../constants/PropUnit.js'); const PropAccess = require('../../../constants/PropAccess.js'); class ChuangmiPlugV1 extends OutletDevice { constructor(miotDevice, name, logger) { super(miotDevice, name, logger); } /*----------========== DEVICE INFO ==========----------*/ getDeviceName() { return 'Xiaomi Chuangmi Plug V1'; } getMiotSpecUrl() { return 'https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:outlet:0000A002:chuangmi-v1:2'; } /*----------========== CONFIG ==========----------*/ requiresMiCloud() { return true; } /*----------========== METADATA ==========----------*/ initDeviceServices() { this.createServiceByString('{"siid":2,"type":"urn:miot-spec-v2:service:switch:0000780C:chuangmi-v1:1","description":"Power Switch Status"}'); this.createServiceByString('{"siid":3,"type":"urn:miot-spec-v2:service:indicator-light:00007803:chuangmi-v1:2","description":"Indicator Light"}'); } initDeviceProperties() { this.addPropertyByString('switch:on', '{"siid":2,"piid":1,"type":"urn:miot-spec-v2:property:on:00000006:chuangmi-v1:1","description":"Switch Status","format":"bool","access":["read","write","notify"]}'); this.addPropertyByString('indicator-light:on', '{"siid":3,"piid":1,"type":"urn:miot-spec-v2:property:on:00000006:chuangmi-v1:2","description":"Switch Status","format":"bool","access":["read","write","notify"]}'); } initDeviceActions() { //no actions } initDeviceEvents() { //no events } /*----------========== VALUES OVERRIDES ==========----------*/ /*----------========== PROPERTY OVERRIDES ==========----------*/ /*----------========== ACTION OVERRIDES ==========----------*/ /*----------========== OVERRIDES ==========----------*/ } module.exports = ChuangmiPlugV1;