Closed Pittini closed 3 years ago
I can't find the model zhimi.airpurifier.mb3 in my current devices database, and I don't have that device too. So because you confirm all functions of that device are the same as model zhimi.airpurifier.ma4, I can add that model and it will be update when I have more information. You can update update new version and try to control your device
I cant confirm the functions are exactly the same, but i think so. I think the difference between the devices is only the localisation, the AirPurifier3 is chinese Version and 3H is the European Version. So it seems to be logic the functions are the same. When you have added the model, i can try to control it. I'm working with iobroker und atm im trying to find out how i can use it, because the "await" Async Fucntion from your example doesnt exists in iobroker (i think).
Thanks for the fast add, but there is a little error, you named it .mb4 but it should be .mb3 (see the first post). Please correct this.
Tryed to rename the file by myself and also corrected it inside but all i got is:
`
javascript.0 | 2020-11-12 11:08:24.932 | error | (11653) at Script.runInContext (vm.js:130:18) |
---|---|---|---|
javascript.0 | 2020-11-12 11:08:24.932 | error | (11653) at script.js.common.Test_Purifier:64:3 |
javascript.0 | 2020-11-12 11:08:24.931 | error | (11653) at script.js.common.Test_Purifier:6:23 |
javascript.0 | 2020-11-12 11:08:24.931 | error | (11653) at Object.createDevice [as device] (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-mihome/lib/device.js:8:11) |
javascript.0 | 2020-11-12 11:08:24.931 | error | (11653) script.js.common.Test_Purifier: Error: Model zhimi.airpurifier.mb3 is not supported |
` Did i forgot something?
sr, my mistake, you can upgrade new version and try again
Ok, thank you. I've updated to 0.27 and tryed, but poorly no success. Whatever i do, i got:
(11653) script.js.common.Test_Purifier: Error: Model zhimi.airpurifier.mb3 is not supported
I found this Message in your code, so i think my script has a proper call to the function. Here is the code i used for testing, i would appreciate some help because i dont know where the error is.
Any suggestions?.
const mihome = require('node-mihome');
// local miIO
mihome.miioProtocol.init();
const device = mihome.device({
id: '317335021', // required, device id
model: 'zhimi.airpurifier.mb3', // required, device model
address: '192.168.2.136', // miio-device option, local ip address
token: '4ff8a96292d045c5148142a0a851e4f', // miio-device option, device token
refresh: 30000 // miio-device option, device properties refresh interval in ms
//parent: '1234abcd', // aqara-device option, gateway SID for aqara-protocol compatible device
});
device.on('properties', (data) => {
log(properties);
});
test();
async function test() {
await device.setPower(true); // call the method
await device.init(); // connect to device and poll for properties
device.destroy();
}
Ok, i did a lot of tests. First, here are some Device Informations for you, there is also my Humidifier inside which is missing in your Devices List, and some other Devices. Here the json i got from your module:
[{'did':'317335021','token':'4ff8a96292d0451c5148142a0a851e4f','longitude':'0.00000000','latitude':'0.00000000','name':'Mi Air Purifier 3/3H','pid':'0','localip':'192.168.2.136','mac':'5C:E5:0C:C7:E6:68','ssid':'WLAN-739122','bssid':'98:9B:CB:00:32:2C','parent_id':'','parent_model':'','show_mode':1,'model':'zhimi.airpurifier.mb3','adminFlag':1,'shareFlag':0,'permitLevel':16,'isOnline':true,'desc':'Device online ','extra':{'isSetPincode':0,'fw_version':'2.0.7','needVerifyCode':0,'isPasswordEncrypt':0,'mcu_version':'0017'},'uid':6197496208,'pd_id':1182,'password':'','p2p_id':'','rssi':-48,'family_id':0,'reset_flag':0},{'did':'132369115','token':'ed4412d6929f393d26e48618be290bb9','longitude':'0.00000000','latitude':'0.00000000','name':'Yeelight LED Bulb (Color)','pid':'0','localip':'192.168.2.118','mac':'04:CF:8C:97:3A:09','ssid':'WLAN-739122','bssid':'98:9B:CB:00:32:2C','parent_id':'','parent_model':'','show_mode':1,'model':'yeelink.light.color2','adminFlag':1,'shareFlag':0,'permitLevel':16,'isOnline':true,'desc':'Device online ','extra':{'isSetPincode':0,'fw_version':'2.0.6_0065','needVerifyCode':0,'isPasswordEncrypt':0},'uid':6197496208,'pd_id':436,'password':'','p2p_id':'','rssi':-86,'family_id':0,'reset_flag':0},{'did':'133168119','token':'a1023ea902a75d237475d46f81a1c20f','longitude':'0.00000000','latitude':'0.00000000','name':'Yeelight LED Bulb (Tunable)2','pid':'0','localip':'192.168.2.128','mac':'04:CF:8C:A3:6B:25','ssid':'WLAN-739122','bssid':'98:9B:CB:00:32:2C','parent_id':'','parent_model':'','show_mode':1,'model':'yeelink.light.ct2','adminFlag':1,'shareFlag':0,'permitLevel':16,'isOnline':true,'desc':'Device online ','extra':{'isSetPincode':0,'fw_version':'1.4.2_0016','needVerifyCode':0,'isPasswordEncrypt':0},'uid':6197496208,'pd_id':526,'password':'','p2p_id':'','rssi':-45,'family_id':0,'reset_flag':0},{'did':'133169476','token':'ccf638dbbcb6a9216895d71e11b0ac39','longitude':'0.00000000','latitude':'0.00000000','name':'Yeelight LED Bulb (Tunable)','pid':'0','localip':'192.168.2.127','mac':'04:CF:8C:A3:70:72','ssid':'WLAN-739122','bssid':'98:9B:CB:00:32:2C','parent_id':'','parent_model':'','show_mode':1,'model':'yeelink.light.ct2','adminFlag':1,'shareFlag':0,'permitLevel':16,'isOnline':true,'desc':'Device online ','extra':{'isSetPincode':0,'fw_version':'1.4.2_0016','needVerifyCode':0,'isPasswordEncrypt':0},'uid':6197496208,'pd_id':526,'password':'','p2p_id':'','rssi':-72,'family_id':0,'reset_flag':0},{'did':'133177899','token':'f142af15b8ae5a0ef78df7fc0a1f2059','longitude':'0.00000000','latitude':'0.00000000','name':'Yeelight Lightstrip Plus','pid':'0','localip':'192.168.2.138','mac':'04:CF:8C:A3:91:59','ssid':'WLAN-739122','bssid':'98:9B:CB:00:32:2C','parent_id':'','parent_model':'','show_mode':1,'model':'yeelink.light.strip2','adminFlag':1,'shareFlag':0,'permitLevel':16,'isOnline':true,'desc':'Device online ','extra':{'isSetPincode':0,'fw_version':'2.0.6_0073','needVerifyCode':0,'isPasswordEncrypt':0},'uid':6197496208,'pd_id':585,'password':'','p2p_id':'','rssi':-66,'family_id':0,'reset_flag':0},{'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}]
Second, i think there is an error in your example. You wrote this:
device.on('properties', (data) => {
console.log(properties);
});
but i think i should be like this (pls correct me if im wrong):
device.on('properties', (data) => {
console.log(data);
});
So, you see, the login works, i got the list back. But then... i dont know what do do. I tried the createDevice but still got ever a
javascript.0 | 2020-11-13 18:56:30.219 | error | (19463) at Object.createDevice [as device] (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-mihome/lib/device.js:8:11)
-- | -- | -- | --
javascript.0 | 2020-11-13 18:56:30.218 | error | (19463) script.js.common.Test_Purifier: Error: Model zhimi.airpurifier.mb3 is not supported
My actual code looks like this, it would be very nice if you can give me a working example how to switch on/off my Purifier, cause its not so much documented. What has to be insertet inside the brackets here:
await mihome.miCloudProtocol.getDevices([deviceId1, deviceId2, ...], options); // get devices information from list ids
If i try this with an DeviceID as suggested, i got:
javascript.0 | 2020-11-13 20:01:13.952 | error | (19463) at MiCloudProtocol.getDevices (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-mihome/lib/protocol-micloud.js:123:24)
-- | -- | -- | --
javascript.0 | 2020-11-13 20:01:13.951 | error | (19463) script.js.common.Test_Purifier: TypeError: Cannot read property 'list' of null
Here my actual code:
const mihome = require('node-mihome');
Init();
async function Init() {
// local miIO
mihome.miioProtocol.init();
// local Aqara (ZigBee)
//mihome.aqaraProtocol.init();
// cloud MIoT
const username = 'x@web.de';
const password = 'xxxxx';
//await mihome.miCloudProtocol.login(username, password);
const options = { country: 'de' }; // 'ru', 'us', 'tw', 'sg', 'cn', 'de' (Default: 'cn')
await mihome.miCloudProtocol.getDevices(null, options); // return all devices from your acount with all information (deviceId, token, model ...) to create device in the next step
console.warn(await mihome.miCloudProtocol.getDevices(null, options))
console.warn(await mihome.miCloudProtocol.getDevices([317335021],options)); // get devices information from list ids
// await mihome.miCloudProtocol.miioCall(deviceId, method, params, options); // call miio method with params via cloud protocol
Create_device();
}
async function Create_device() {
const device = mihome.device({
id: '317335021', // required, device id
model: 'zhimi.airpurifier.mb3', // required, device model "zhimi.airpurifier.mb3"
address: '192.168.2.136', // miio-device option, local ip address
token: '4ff8a96292d0451c5148142a0a851e4f', // miio-device option, device token 4ff8a96292d0451c5148142a0a851e4f
refresh: 30000 ,// miio-device option, device properties refresh interval in ms
parent: '', // aqara-device option, gateway SID for aqara-protocol compatible device
});
device.on('properties', (data) => {
console.log(data);
});
await device.setPower(false); // call the method
await device.init(); // connect to device and poll for properties
device.destroy();
}
A lot of hours later, i got a connection and get back the controls from the Purifier BUT:
the code trys to got the Powerstate: await device.getPower(); , but i got the complete list back (better than nothing), like:
{'air-purifier:fault':0,'air-purifier:on':true,'air-purifier:fan-level':1,'air-purifier:mode':1,'environment:pm2.5-density':14,'environment:relative-humidity':46,'environment:temperature':19.1,'filter:filter-life-level':94,'filter:filter-used-time':194,'alarm:alarm':false,'indicator-light:brightness':1,'indicator-light:on':true,'physical-controls-locked:physical-controls-locked':false}
And everytime i try: await device.setPower(false); i got an error like:
javascript.0 | 2020-11-15 11:35:30.172 | error | (1340) at module.exports.setPower (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-mihome/lib/devices/zhimi.airpurifier.mb3.js:77:17)
-- | -- | -- | --
javascript.0 | 2020-11-15 11:35:30.172 | error | (1340) at module.exports.miotSetProperty (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-mihome/lib/device-miio.js:158:13)
javascript.0 | 2020-11-15 11:35:30.172 | error | (1340) script.js.common.Test_Purifier: Error: This device don't config miot spec
So there, maybe is an error in the new airpurifier.mb3 devicefile. I found inside:
this._miotSpecType = 'urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma4:2';
Shouldnt it be?:
this._miotSpecType = 'urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-mb3:2';
Ok, help would been nice, but after a couple of weeks without any response, i figured it out by myself and corrected all Errors. Please merge the pullrequest. Then this Issue can be closed.
Please post your code and full logs The error 'This device don't config miot spec' mean have a error when fetch the miot spec when init the device and the error was throw
As i said, merging the pull request is all needed, everything is fine now.
Hi, there is still integrated the AirPurifier 3 as zhimi.airpurifier.ma4 I have the AirPurifier 3H and thats named zhimi.airpurifier.mb3 (DeviceId= 317335021) the functions are the same with the model3 you have. Can you please integrate the 3H? Thanks