marvinroger / node-lumi-aqara

Control your Xiaomi Smart Home devices with this Lumi Aqara library
GNU General Public License v3.0
46 stars 27 forks source link

Cannot read property '_handleState' of undefined #2

Closed Shuunen closed 7 years ago

Shuunen commented 7 years ago

Hi there :)

First thanks for the lib, working well, I manage to catch my xiaomi switch click in under a minute of setup, great !

But I have this error after :

Gateway discovered

Light updated: {"color":{"r":0,"g":0,"b":0},"intensity":0}

Gateway is ready

not handled: {"cmd":"read_ack","model":"sensor_ht","sid":"15xxxxxea6","short_id":24660,"data":"{\"voltage\":3005,\"temperature\":\"2447\",\"humidity\":\"490
4\"}"}

New device
  Battery: 55.00000000000001%
  Type: magnet
  SID: 158xxxxxeef
  Magnet (close)

New device
  Battery: 53.6%
  Type: switch
  SID: 15xxxxxd0
  Switch

not handled: {"cmd":"read_ack","model":"motion","sid":"15xxxxx06","short_id":61156,"data":"{\"voltage\":3045,\"status\":\"motion\"}"}

not handled: {"cmd":"read_ack","model":"plug","sid":"15xxxxxc8","short_id": 26348,"data":"{\"voltage\":3600,\"status\":\"unknown\",\"inuse\":\"0\"}"}

C:\mi-tests\node_modules\lumi-aqara\src\lib\gateway.js:89
        else this._subdevices.get(msg.sid)._handleState(state)
                                          ^

TypeError: Cannot read property '_handleState' of undefined
    at Gateway._handleMessage (C:\mi-tests\node_modules\lumi-aqara\src\lib\gateway.js:89:43)
    at LumiDiscoverer._handleMessage (C:\mi-tests\node_modules\lumi-aqara\src\index.js:68:27)
    at emitTwo (events.js:106:13)
    at Socket.emit (events.js:191:7)
    at UDP.onMessage (dgram.js:550:8)

any idea ?

Shuunen commented 7 years ago

Ok I investigate and found that in gateway.js line 89 you are looking for this._subdevices.get(msg.sid)

But here msg.sid refers to a non-handled device so it crash , I will submit a PR

marvinroger commented 7 years ago

Thanks for the kind word. 👍

Yes, these are devices I don't own, so a PR with the devices you have would be great! 😊 That's what the non-handled logs are for.

Le 10 juin 2017 3:39 PM, "Romain Racamier" notifications@github.com a écrit :

Ok I investigate and found that in gateway.js line 89 you are looking for this._subdevices.get(msg.sid)

But here msg.sid refers to a non-handled device so it crash , I will submit a PR

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/marvinroger/node-lumi-aqara/issues/2#issuecomment-307565675, or mute the thread https://github.com/notifications/unsubscribe-auth/AA8eNQUkP_X-JTfxgTAzeaaWWDeneE02ks5sCpx9gaJpZM4N2HOT .