Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue connecting the window sensor: Cannot read property 'modelId' of undefined #6

Closed
flatsiedatsie opened this issue Jul 31, 2019 · 5 comments

Comments

@flatsiedatsie
Copy link
Collaborator

I have managed to install the add-on manually, I think. The Zigbee2mqtt software is running in a terminal window, and when I press the button on the Aqara window sensor for 3 seconds I can see some messages scroll by. It seems Zigbee2MQTT is working.

The add-on also show some activity at the same time: it crashes.

2019-07-31 11:29:42.767 INFO   : Opened a new things socket
2019-07-31 11:29:48.170 ERROR  : zigbee2mqtt: /home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/zigbee2mqtt-adapter.js:83
2019-07-31 11:29:48.171 ERROR  : zigbee2mqtt:       const description = Devices[msg.device.modelId];
2019-07-31 11:29:48.172 ERROR  : zigbee2mqtt:                                              ^
2019-07-31 11:29:48.173 ERROR  : zigbee2mqtt: 
2019-07-31 11:29:48.174 ERROR  : zigbee2mqtt: TypeError: Cannot read property 'modelId' of undefined
2019-07-31 11:29:48.175 ERROR  : zigbee2mqtt:     at ZigbeeMqttAdapter.handleIncomingMessage (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/zigbee2mqtt-adapter.js:83:46)
2019-07-31 11:29:48.176 ERROR  : zigbee2mqtt:     at emitThree (events.js:136:13)
2019-07-31 11:29:48.176 ERROR  : zigbee2mqtt:     at MqttClient.emit (events.js:217:7)
2019-07-31 11:29:48.177 ERROR  : zigbee2mqtt:     at MqttClient._handlePublish (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/node_modules/mqtt/lib/client.js:987:12)
2019-07-31 11:29:48.179 ERROR  : zigbee2mqtt:     at MqttClient._handlePacket (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/node_modules/mqtt/lib/client.js:336:12)
2019-07-31 11:29:48.180 ERROR  : zigbee2mqtt:     at work (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/node_modules/mqtt/lib/client.js:292:12)
2019-07-31 11:29:48.181 ERROR  : zigbee2mqtt:     at Writable.writable._write (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/node_modules/mqtt/lib/client.js:302:5)
2019-07-31 11:29:48.182 ERROR  : zigbee2mqtt:     at doWrite (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/node_modules/readable-stream/lib/_stream_writable.js:428:64)
2019-07-31 11:29:48.182 ERROR  : zigbee2mqtt:     at writeOrBuffer (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/node_modules/readable-stream/lib/_stream_writable.js:417:5)
2019-07-31 11:29:48.183 ERROR  : zigbee2mqtt:     at Writable.write (/home/pi/.mozilla-iot/addons/zigbee2mqtt-adapter/node_modules/readable-stream/lib/_stream_writable.js:334:11)
@flatsiedatsie
Copy link
Collaborator Author

I checked with mosquitt_sub what the incoming message looked like.

Client mosqsub|23184-gateway received PUBLISH (d0, q0, r0, m0, 'zigbee2mqtt/bridge/config/devices', ... (335 bytes))
[{"ieeeAddr":"0x00124b0xxxxx","type":"Coordinator"},{"ieeeAddr":"0x00158d000xxxxx","type":"EndDevice","model":"MCCGQ11LM","friendly_name":"0x0015xxxxx","nwkAddr":5xxxxx,"manufId":4xxx,"manufName":"LUMI","powerSource":"Battery","modelId":"lumi.sensor_magnet.aq2","hwVersion":2,"swBuildId":"3xxx-xxxx","dateCode":"20161128"}]

Strangely, modelId is in there.

@flatsiedatsie
Copy link
Collaborator Author

I think I've cracked it: this version of the magnetic contact sensor was not in the supported devices list.

Perhaps there could be a fuzzy matching heuristic where only the first two parts of the modelId have to match?

@flatsiedatsie
Copy link
Collaborator Author

I've created a pull request to add this device.

It might be nice to create more expressive error messages when this is the issue, so the user knows what to do.

@kabbi
Copy link
Owner

kabbi commented Aug 12, 2019

Yeah, I think we should add a proper error message for unsupported devices. Will definitely look into this

@flatsiedatsie
Copy link
Collaborator Author

How do you feel about the fuzzy matching? Could that work? Or will that only lead to issues? I don't know if the convention that Xiaomi/other companies use is in any way predictable. E.g. that the string after the second dot is just a version upgrade without a fundamentally change to how things work. Then again, this case already hinted that version 2 of the magnetic contact sensor works differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants