Closed Pittini closed 3 years ago
Are you sure that device use miot protocol? You can share me that device in MiHome app, I will collect some data to make new supported model
I've figured it out by myself meanwhile. This is testet and working. Nothing to do for you, just insert as zhimi.humidifier.cb1.js please.
const Device = require('../device-miio');
module.exports = class extends Device {
static model = 'zhimi.humidifier.cb1';
static name = 'Smartmi Evaporative Humidifier';
static image = 'http://static.home.mi.com/app/image/get/file/developer_1543307568u9wu6wij.png';
constructor(opts) {
super(opts);
// this._miotSpecType = 'urn:miot-spec-v2:device:humidifier:0000A00E:zhimi-cb1:1';
this._propertiesToMonitor = [
'limit_hum',
'power',
'humidity',
'temperature',
'buzzer',
'led',
'depth',
'dry',
'child_lock',
'mode'];
}
getLimitHum() {
return this.properties['limit_hum'];
}
getLed() {
return this.properties['led'];
}
getDry() {
return this.properties['dry'];
}
getChildLock() {
return this.properties['child_lock'];
}
getPower() {
const power = this.properties['power'];
if (power == 'on') return true;
else if (power == 'off') return false;
else return undefined;
}
getMode() {
const mode = this.properties['mode'];
if (mode === 'auto') return 0;
else if (mode === 'silent') return 1;
else if (mode === 'medium') return 2;
else if (mode === 'high') return 3;
else return undefined
}
getDepth() { // 0-100%
return this.properties['depth'];
}
getTemperature() {
return this.properties['temperature'];
}
getHumidity() {
return this.properties['humidity'];
}
getBuzzer() {
return this.properties['buzzer'];
}
setPower(v) {
return this.miioCall('set_power', [v ? 'on' : 'off']);
}
setBuzzer(v) {
return this.miioCall('set_buzzer', [v]);
}
setMode(v) {
if (v === 0) v = 'auto';
else if (v === 1) v = 'silent';
else if (v === 2) v = 'medium';
else if (v === 3) v = 'high';
return this.miioCall('set_mode', [v]);
}
setLimitHum(v) {
return this.miioCall('set_limit_hum',[v]);
}
setLed(v) {
return this.miioCall('set_led_b', [String(v)]);
}
setChildLock(v) {
return this.miioCall('set_child_lock');
}
setDry(v) {
return this.miioCall('set_dry');
}
};
New model zhimi.humidifier.cb1
have been added at: https://github.com/maxinminax/node-mihome/blob/master/lib/devices/zhimi.humidifier.cb1.js
I changed some methods to made the consistent of namespace with other models and added the device image too
I have not published to npm yet, Pls install this package with github link, test and confirm it work well before I publish to npm
I've tested it locally after your changes. I had to change some of my code, but its working now, can be published i think.
Little explanation: I have to define every Device again inside my code, because i need read/write/datatype and some other info for creating datapoints in iobroker. Atm such a definition looks like this:
DefineDevice[3] = {
info: {},
model: "zhimi.humidifier.cb1",// https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:humidifier:0000A00E:zhimi-cb1:1
description: "Smartmi Evaporative Humidifier",
setter: {
"power": async function (obj, val) { await device[obj].setPower(val) },
"buzzer": async function (obj, val) { await device[obj].setBuzzer(val) },
"mode": async function (obj, val) { await device[obj].setFanLevel(val) },
"limit_hum": async function (obj, val) { await device[obj].setTargetHumidity(val) },
"led": async function (obj, val) { await device[obj].setLedBrightness(val) },
"child_lock": async function (obj, val) { await device[obj].setChildLock(val) },
"dry": async function (obj, val) { await device[obj].setMode(val) }
},
common:
[{ name: "power", format: "boolean", read: true, write: true, min: false, max: true },
{ name: "depth", format: "number", read: true, write: false, min: 0, max: 100, unit: "%" },
{ name: "limit_hum", format: "number", read: true, write: true, min: 0, max: 100, unit: "%" , states: { 30: "30%", 40: "40%", 50: "50%",60: "60%", 70: "70%", 80: "80%" }},
{ name: "led", format: "number", read: true, write: true, min: 0, max: 2, states: { 0: "bright", 1: "dim", 2: "off" } },
{ name: "buzzer", format: "boolean", read: true, write: true, min: false, max: true },
{ name: "temperature", format: "number", read: true, write: false, min: -40, max: 125, unit: "°C" },
{ name: "humidity", format: "number", read: true, write: false, min: 0, max: 100, unit: "%" },
{ name: "child_lock", format: "boolean", read: true, write: true, min: false, max: true },
{ name: "dry", format: "boolean", read: true, write: true, min: false, max: true },
{ name: "mode", format: "string", read: true, write: true, states: { "auto": "auto", "silent": "silent", "medium": "medium", "high": "high" } }]
};
Works fine, closing
Here are the found Data for the Device:
{'did':'312463870','token':'c503bee5cabc68edaf72c2d5b4ddcf62','longitude':'0.00000000','latitude':'0.00000000','name':'Smartmi Evaporative Humidifier','pid':'0','localip':'192.168.2.150','mac':'5C:E5:0C:84:6A:B9','ssid':'WLAN-739122','bssid':'98:9B:CB:00:32:2C','parent_id':'','parent_model':'','show_mode':1,'model':'zhimi.humidifier.cb1','adminFlag':1,'shareFlag':0,'permitLevel':16,'isOnline':true,'desc':'Device online ','extra':{'isSetPincode':0,'fw_version':'1.6.7','needVerifyCode':0,'isPasswordEncrypt':0,'mcu_version':'1005'},'uid':6197496208,'pd_id':1135,'password':'','p2p_id':'','rssi':-56,'family_id':0,'reset_flag':0}
Additional Infos i found: Generic Infos about all models: http://miot-spec.org/miot-spec-v2/instances?status=all
Link to Humidifier: http://miot-spec.org/miot-spec-v2/spec/service?type=urn:miot-spec-v2:device:humidifier:0000A00E
Service Data to Humidifier: {"type":"urn:miot-spec-v2:device:humidifier:0000A00E","description":"Humidifier","required-services":["urn:miot-spec-v2:service:device-information:00007801","urn:miot-spec-v2:service:humidifier:00007818"],"optional-services":["urn:miot-spec-v2:service:environment:0000780A","urn:miot-spec-v2:service:filter:0000780B"]}
Link to the Product including also an Image: https://www.banggood.com/Smartmi-CJXJSQ02ZM-Evaporation-Air-Humidifier-240ml-or-h-4L-Capacity-Touch-Control-with-APP-Control-Low-Noise-p-1266720.html?ID=564581&cur_warehouse=HK