maxinminax / node-mihome

Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more
MIT License
121 stars 34 forks source link

Error: This device don't config miot spec on Xiaomi Mi Air Purifier 2H #30

Open fuomag9 opened 3 years ago

fuomag9 commented 3 years ago

When I try to run the following code I get UnhandledPromiseRejectionWarning: Error: This device don't config miot spec on a Xiaomi Mi Air Purifier 2H. The device works fine and can be correctly read with the miio library

const mihome = require('node-mihome');
mihome.miioProtocol.init();
const options = { country: 'en' };

async function f() {
    const device = mihome.device({
        id: '▀▀▀▀', // required, device id
        model: 'zhimi.airpurifier.mc2', // required, device model

        address: '▀▀▀▀', // miio-device option, local ip address
        token: '▀▀▀▀▀', // miio-device option, device token
        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(true); // call the method
    await device.init(); // connect to device and poll for properties
    device.destroy();
}

f()
UnhandledPromiseRejectionWarning: Error: This device don't config miot spec
    at module.exports.miotSetProperty (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\node_modules\node-mihome\lib\device-miio.js:158:13)
    at module.exports.setPower (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\node_modules\node-mihome\lib\devices\zhimi.airpurifier.mc2.js:71:17)
    at f (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\index.js:65:18)
    at Object.<anonymous> (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\index.js:70:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
Pittini commented 3 years ago

Try to remove the 'parent' line and the semikolon after refresh:3000

fuomag9 commented 3 years ago

Try to remove the 'parent' line and the semikolon after refresh:3000

Same error as before

Pittini commented 3 years ago

Try to remove the 'parent' line and the semikolon after refresh:3000

Same error as before

Ok, i dont know your skills, but eventually you can extrakt working code from my skript here. This worked fine with the 3H. https://github.com/Pittini/iobroker-nodemihome/blob/main/old/Airpurifier3H-V0.1.6.js

caomeiguojiang commented 3 years ago

try device.init() before device.setPower(true)

fuomag9 commented 3 years ago

try device.init() before device.setPower(true)

(node:3432) UnhandledPromiseRejectionWarning: Error: Method not found.
    at Object.reject (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\node_modules\node-mihome\lib\protocol-miio.js:343:19)
    at MiIOProtocol._onData (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\node_modules\node-mihome\lib\protocol-miio.js:239:11)
    at MiIOProtocol._onMessage (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\node_modules\node-mihome\lib\protocol-miio.js:110:14)
    at Socket.<anonymous> (C:\Users\fuomag9\Documents\Dev\MiPurifierStuff\node_modules\node-mihome\lib\protocol-miio.js:40:12)
    at Socket.emit (events.js:315:20)
    at UDP.onMessage [as onmessage] (dgram.js:919:8)

Still not working unfortunately, plus per https://github.com/maxinminax/node-mihome/blob/master/README.md device.init() is called after device.setPower(true), so one of those is wrong