seikan / homebridge-xiaomi-mi-robot-vacuum

XiaoMi Mi robot vacuum plugin for Homebridge.
Other
64 stars 8 forks source link

miio.createDevice is not a function #16

Closed tomohnejerry closed 6 years ago

tomohnejerry commented 6 years ago

Loading 1 accessories... [2018-1-25 10:04:28] [Vacuum Cleaner] Initializing MiRobotVacuum accessory... /usr/lib/node_modules/homebridge-xiaomi-mi-robot-vacuum/index.js:88 this.device = miio.createDevice({ ^

TypeError: miio.createDevice is not a function at Object.discover (/usr/lib/node_modules/homebridge-xiaomi-mi-robot-vacuum/index.js:88:22) at Object.MiRobotVacuum (/usr/lib/node_modules/homebridge-xiaomi-mi-robot-vacuum/index.js:78: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)

something I didn't see?

tomohnejerry commented 6 years ago

Setup is: Robot: Roborock S50 Router: Fritz!Box 7490

Setup with same token and IP does work well for my ioBroker Adapter. Feel free to ask me for more details

aebgit commented 6 years ago

...same here. This is caused by a broken dependency with the recently updated miio

$ miio --version
0.15.5

You could try to downgrade miioto 0.14.1 which should compatible with the current-version of the xiaomi-homebridge plugin: $ sudo npm install -g miio@0.14.1

This worked for me.

marco79cgn commented 6 years ago

Thanks @aebgit - this solved the problem for me as well.

Obviously there have been a lot of changes in miio 0.15.x which are not backward compatible. So the package.json of this project here should be changed to "miio": "0.14.1" until problems are resolved (cc @seikan).

pistol commented 6 years ago

Going back to miio@0.14.1 doesn't solve it for me. I tried pairing it with older versions homebridge-xiaomi-mi-robot-vacuum without luck:

homebridge-xiaomi-mi-robot-vacuum@1.0.0 '1.0.0'
homebridge-xiaomi-mi-robot-vacuum@1.1.0 '1.1.0'
homebridge-xiaomi-mi-robot-vacuum@1.1.1 '1.1.1'
homebridge-xiaomi-mi-robot-vacuum@1.2.0 '1.2.0'

Any workaround ideas?

[2018-2-7 09:18:33] Homebridge is running on port 51826.
(node:1686) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Not able to initialize robot vacuum.
(node:1686) [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.

PS: Does the config.json accessories token have to be 36 or 96 chars long?

P1xellat3d commented 6 years ago

@pistol The token needs to be 32 chars and not 92. Xiaomi encrypted these with a simple key which you can decrypt using 32 zeros:

echo '0: <YOUR HEXADECIMAL STRING>' | xxd -r -p | openssl enc -d -aes-128-ecb -nopad -nosalt -K 00000000000000000000000000000000

JeriMind commented 6 years ago

Hi Mates, the workaround with downgrading miio to 0.14.1 works as well. unfortunately my sd card is broken without backup.. so I setup all new...:

now I have this problem:

root@raspberrypi:/home/pi# miio --version ERROR Unsupported mode root@raspberrypi:/home/pi# npm install -g miio /usr/local/bin/miio -> /usr/local/lib/node_modules/miio/cli/index.js

and with the new 0.15.6 I get the error too:

TypeError: miio.createDevice is not a function at MiRobotVacuum.discover (/usr/local/lib/node_modules/homebridge-xiaomi-mi-robot-vacuum/index.js:88:22) at new MiRobotVacuum (/usr/local/lib/node_modules/homebridge-xiaomi-mi-robot-vacuum/index.js:78: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:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Function.Module.runMain (module.js:684:10) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3 root@raspberrypi:/home/pi#

root@raspberrypi:/home/pi# npm -v 5.6.0 root@raspberrypi:/home/pi# node -v v8.9.4

any ideas?

P1xellat3d commented 6 years ago

@JeriMind Downgrade miio to 0.14.1 using:

sudo npm install -g miio@0.14.1

Since 0.15.x releases of miio, it looks like many plugins will need updating (including this one) if you want to see it work.

It also looks like since 0.15.x parameters don’t need the two hyphens anymore hence the ERROR Unsupported mode.

I have many plugins and 0.14.1 seems to work fine for everything so far.

JeriMind commented 6 years ago

hi @P1xellat3d yes with 0.14.1 it seems it works... but I get this error

[2018-3-3 15:57:51] Homebridge is running on port 51826. (node:1837) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Not able to initialize robot vacuum. (node:1837) [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.

P1xellat3d commented 6 years ago

(node:1837) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Not able to initialize robot vacuum.

@JeriMind There is something wrong with the way you have configured the vacuum. Are you using the correct Token and is it 32 chars long?

ramsterdam85 commented 6 years ago

@JeriMind, I'm having the same error using miio 0.14.1, while newer versions give me the @tomohnejerry error. In my case, homebridge runs for a while is launched from withing a terminal but ends up crashing, and fails nearly instantly as a boot process through systemd (on headless pi 3). Anyone find a workaround? @P1xellat3d Not sure this is token-related, using both 0.14.1 and later versions of miio in debug with the same token it will read out data and allow me to control the device for a while before homebridge crashes.

ramsterdam85 commented 6 years ago

@aholstenson , sorry to pull you in here out of the blue, but is the TypeError: miio.createDevice is not a function error discussed here maybe related to the way/version of miio is used in this plugin?

aholstenson commented 6 years ago

Yes, this is related to Miio 0.15 being released and that this plugin only works with 0.14. This plugin needs to be updated to work with the new version and should declare the version needed under packages in package.json. Doing so would ensure that the installation pulls in the correct version of Miio as a local dependency.

seikan commented 6 years ago

This issue has been resolved in latest version.