homebridge-miot
Version:
Homebridge plugin for devices supporting the miot protocol
94 lines (71 loc) • 2.67 kB
JavaScript
const FanDevice = require('../FanDevice.js');
const Properties = require('../../../constants/Properties.js');
const Actions = require('../../../constants/Actions.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 ZhimiFanV3 extends FanDevice {
constructor(model, deviceId, name, logger) {
super(model, deviceId, name, logger);
}
/*----------========== DEVICE INFO ==========----------*/
static getDeviceModel() {
return "zhimi.fan.v3";
}
getDeviceName() {
return "Smartmi Standing Fan V3";
}
getDeviceMiotSpec() {
return "https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:zhimi-v3:1";
}
requiresMiCloud() {
return true;
}
/*----------========== INIT ==========----------*/
initDeviceProperties() {
// READ/WRITE
this.addProperty(Properties.POWER, 2, 1, PropFormat.BOOL, PropAccess.READ_WRITE_NOTIFY, PropUnit.NONE);
this.addProperty(Properties.FAN_LEVEL, 2, 2, PropFormat.UINT8, PropAccess.READ_WRITE_NOTIFY, PropUnit.NONE, [1, 4, 1]);
this.addProperty(Properties.HORIZONTAL_SWING, 2, 3, PropFormat.BOOL, PropAccess.READ_WRITE_NOTIFY, PropUnit.NONE);
this.addProperty(Properties.HORIZONTAL_SWING_ANGLE, 2, 4, PropFormat.UINT16, PropAccess.READ_WRITE_NOTIFY, PropUnit.NONE, [30, 120, 1]);
this.addProperty(Properties.MODE, 2, 5, PropFormat.UINT8, PropAccess.READ_WRITE_NOTIFY, PropUnit.NONE, [], [{
"value": 0,
"description": "Straight Wind"
},
{
"value": 1,
"description": "Natural Wind"
}
]);
this.addProperty(Properties.CHILD_LOCK, 3, 1, PropFormat.BOOL, PropAccess.READ_WRITE_NOTIFY, PropUnit.NONE);
// READ ONLY
this.addProperty(Properties.BATTERY_LEVEL, 4, 1, PropFormat.UINT8, PropAccess.READ_NOTIFY, PropUnit.PERCENTAGE, [0, 100, 1]);
this.addProperty(Properties.CHARGING_STATE, 4, 2, PropFormat.UINT8, PropAccess.READ_NOTIFY, PropUnit.PERCENTAGE, [], [{
"value": 1,
"description": "Charging"
},
{
"value": 2,
"description": "Charge Complete"
}
]);
}
initDeviceActions() {
this.addAction(Actions.TOGGLE, 2, 1, []);
}
/*----------========== CONFIG ==========----------*/
straightWindModeValue() {
return 0;
}
naturalModeValue() {
return 1;
}
hasBuiltInBattery() {
return true;
}
emulateSteplessFanSpeed() {
return true;
}
}
module.exports = ZhimiFanV3;