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

Avoid crash when dealing with un-handled devices #3

Closed Shuunen closed 6 years ago

Shuunen commented 7 years ago

As described in https://github.com/marvinroger/node-lumi-aqara/issues/2

svrooij commented 6 years ago

This pull-request might be unnecessary now that this pull request is accepted?

svrooij commented 6 years ago

I don't now how to edit someone else his pull request. But if you want the code to be refactored it should be like:

else {
  var subdevice = this._subdevices.get(msg.sid);
  if (subdevice) {
    subdevice._handleState(state)
  } else {
    // console.log('did not manage to find device, or device not yet supported')
  }
}