Closed jin9xiao closed 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.
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
I've been searching and troubleshooting this issue for 2 days, but no luck to find a valid solution...
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
thank you, i will try it tonight!!!
[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)