aholstenson / miio

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

Can't connect to Xiaomi Humidifier 2 #233

Open DavyJohnes opened 5 years ago

DavyJohnes commented 5 years ago

Hello everyone! Strange thins happen with this device (zhimi.humidifier.ca1). Once I reset device and connect to WiFi it created, miio works well. It is able to find device via discover as well as connect it in code via miio.device(...). On this step I copied token I got during discover, then I connect device to my WiFi router using Mi Home iOS application. After that, miio is not able to find device neither using discover not in code via miio.device(...). I tiyed to launch code with DEBUG=* and I can't understand what's going on. Please help me with it.

miio:network Grabbing reference to network +0ms
  miio:network Making network active, creating socket +3ms
  miio:packet -> <Buffer 21 31 00 20 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +0ms
  miio:network Network bound to port 55877 +11ms
  miio:packet <- <Buffer 21 31 00 20 00 00 00 00 07 e8 48 da 00 00 01 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +69ms
  miio:packet <- <Buffer 21 31 00 20 00 00 00 00 07 e8 48 da 00 00 01 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +0ms
  thing:miio:pending <- Handshake reply: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +0ms
  thing:miio:132663514 Identifier of device updated +0ms
  thing:miio:132663514 Loading token from storage, device hides token and no token set via options +0ms
  miio:tokens Loading token storage from /Users/home/Library/Application Support/miio/tokens.json +0ms
  miio:tokens Loading tokens +1ms
  thing:miio:132663514 Using manual token: c6ebbca9ef1fbfdb0aada8fc9c5b2f86 +3ms
  thing:miio:132663514 -> (5) {"method":"miIO.info","params":[],"id":1} +2ms
  miio:packet -> <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 62 05 b9 d8 9b b2 d0 de b8 08 e3 6a 65 2b ba bf 2b> +7ms
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 62 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +49ms
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 62 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +0ms
  thing:miio:132663514 <- Handshake reply: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +50ms
  thing:miio:132663514 -> (4) {"method":"miIO.info","params":[],"id":101} +2s
  miio:packet -> <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 63 7d aa b8 58 e2 38 c8 8a e0 5e 4e 6b 86 13 c8 1c> +2s
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 63 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +5ms
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 63 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +0ms
  thing:miio:132663514 <- Handshake reply: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +5ms
  thing:miio:132663514 -> (3) {"method":"miIO.info","params":[],"id":201} +2s
  miio:packet -> <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 65 67 a3 fc 1f 65 0d da 0f 13 e2 37 d4 7e cb 1c c7> +2s
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 65 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +37ms
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 65 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +1ms
  thing:miio:132663514 <- Handshake reply: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +38ms
  thing:miio:132663514 -> (2) {"method":"miIO.info","params":[],"id":301} +2s
  miio:packet -> <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 66 a5 7d 2b b3 c5 fe ef 46 17 ab 26 3f 54 6f 28 8e> +2s
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 66 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +5ms
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 66 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +0ms
  thing:miio:132663514 <- Handshake reply: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +5ms
  thing:miio:132663514 -> (1) {"method":"miIO.info","params":[],"id":401} +2s
  miio:packet -> <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 67 14 8e ef 07 3f f6 da fd 25 fe ef 34 19 e1 e5 d2> +2s
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 67 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +32ms
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 67 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +0ms
  thing:miio:132663514 <- Handshake reply: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +32ms
  thing:miio:132663514 -> (0) {"method":"miIO.info","params":[],"id":501} +2s
  miio:packet -> <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 68 ab 35 c7 a2 02 5b 36 e5 5e 1a 1a 28 6e 4f be 71> +2s
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 68 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +5ms
  miio:packet <- <Buffer 21 31 00 50 00 00 00 00 07 e8 48 da 00 00 01 68 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +0ms
  thing:miio:132663514 <- Handshake reply: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff> +5ms
  miio:network Releasing reference to network +12s
  miio:network Network no longer active, destroying socket +0ms
(node:29683) UnhandledPromiseRejectionWarning: Error: Could not connect to device, token might be wrong
    at enrichPromise.promise.then.then.catch.err (/Users/izuev/Projects/humidi/node_modules/miio/lib/network.js:324:16)
(node:29683) 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)
DavyJohnes commented 5 years ago

BTW, when I first connected Humidifier to my network using MiHome, application suggested me to update Humidifier firmware to latest version and I accepted it. May be that is the reason.