seikan / homebridge-mi-air-purifier

A Xiaomi Mi air purifier plugin for Homebridge.
Other
172 stars 65 forks source link

i study homekit on raspbian,but it is wrong like this #30

Closed jin9xiao closed 6 years ago

jin9xiao commented 6 years ago

[1/25/2018, 1:10:48 PM] [Air Purifier] Initializing MiAirPurifier accessory... /usr/lib/node_modules/homebridge-mi-air-purifier/index.js:110 this.device = new miio.Device({ ^

TypeError: miio.Device is not a constructor at Object.discover (/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:110:17) at Object.MiAirPurifier (/usr/lib/node_modules/homebridge-mi-air-purifier/index.js:105:7) at Server._loadAccessories (/usr/lib/node_modules/homebridge/lib/server.js:275:29) at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:86:38) at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:40:10) at Object. (/usr/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)

Errk87 commented 6 years ago

I am getting this same error when starting homebridge. Any help would be great! Thanks!

[2018-1-25 20:58:10] [Mi Air Crusher! - Livingroom] Initializing MiAirPurifier accessory... /usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:110 this.device = new miio.Device({ ^

TypeError: miio.Device is not a constructor at MiAirPurifier.discover (/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:110:17) at MiAirPurifier (/usr/local/lib/node_modules/homebridge-mi-air-purifier/index.js:105:7) at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:275:29) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:86:38) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12)

Jacob0707 commented 6 years ago

It seems this error message is showing when we are using homebridge-mi-air-purifier config the config.json like the following:

"accessories": [{
    "accessory": "MiAirPurifier",
    "name": "Air Purifier",
            "ip": "192.168.31.xx",
            "token": "xxxxx",
    "showTemperature": true,
    "showHumidity": true,
    "showAirQuality": true
}]

If I uninstalled homebridge-mi-air-purifier and install homebridge-mi-air-purifier2, the following error will be shown and the Air Purifier is no responding in iOS Home app.

(node:7626) UnhandledPromiseRejectionWarning: TypeError: this.addChild is not a function at new module.exports (/usr/lib/node_modules/miio/lib/devices/chuangmi.plug.v1.js:21:8) at network.findDeviceViaAddress.then.device (/usr/lib/node_modules/miio/lib/connectToDevice.js:25:12) at (node:7626) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:7626) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I've been searching and troubleshooting this issue for 2 days, but no luck to find a valid solution...

Jacob0707 commented 6 years ago

I've found the solution. It seems the latest version of miio causes this error. Please initiate the following commands one by one.

sudo npm uninstall -g miio sudo npm install -g miio@0.14.1

And then reload homebridge

jin9xiao commented 6 years ago

thank you, i will try it tonight!!!