Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.76k stars 1.65k forks source link

Unhandled Error - Index Out of Range #42

Closed palitu closed 6 years ago

palitu commented 6 years ago

another error that just popped up... this seems to happen after getting data from a xiaomi temp/humidity sensor WSDCGQ01LM.

buffer.js:977
    throw new RangeError('Index out of range');
    ^

RangeError: Index out of range
    at checkOffset (buffer.js:977:11)
    at Buffer.readUInt8 (buffer.js:1015:5)
    at Object.zcl.header (/home/leigh/apps/zigbee2mqtt/node_modules/zcl-packet/lib/zcl.js:73:24)
    at Object.header (/home/leigh/apps/zigbee2mqtt/node_modules/zigbee-shepherd/lib/components/zcl.js:10:32)
    at dispatchIncomingMsg (/home/leigh/apps/zigbee2mqtt/node_modules/zigbee-shepherd/lib/components/af.js:631:29)
    at Controller.incomingMsgHandler (/home/leigh/apps/zigbee2mqtt/node_modules/zigbee-shepherd/lib/components/af.js:714:12)
    at emitOne (events.js:116:13)
    at Controller.emit (events.js:211:7)
    at Object.bridge._areqEventBridge (/home/leigh/apps/zigbee2mqtt/node_modules/zigbee-shepherd/lib/components/event_bridge.js:15:16)
    at CcZnp.<anonymous> (/home/leigh/apps/zigbee2mqtt/node_modules/zigbee-shepherd/lib/components/controller.js:98:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@0.1.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the zigbee2mqtt@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/leigh/.npm/_logs/2018-05-12T03_54_07_130Z-debug.log
palitu commented 6 years ago

is there any way around this at the moment? I haven't looked through the error to see how trivial it is (i am also no pro when it comes to this)

Should i remove a device that is causing this?

ptvoinfo commented 6 years ago

This error appears with bad (damaged) data packets. This problem appears periodically with all devices. I've patched node_modules\zigbee-shepherd\node_modules\zcl-packet\lib\zcl.js

zcl.header = function (buf) { if (!Buffer.isBuffer(buf)) throw new TypeError('header should be a buffer.');

if(buf.length < 3){ return; } //!!! <======== added
Koenkk commented 6 years ago

Check added, thanks! @ptvoinfo

@palitu please let me know if I can close this issue.

palitu commented 6 years ago

ahh, nope - just got another one after readding a Mijia motion sensor:

buffer.js:977
    throw new RangeError('Index out of range');
    ^

RangeError: Index out of range
    at checkOffset (buffer.js:977:11)
    at Buffer.readUInt8 (buffer.js:1015:5)
    at Object.zcl.header (/app/node_modules/zcl-packet/lib/zcl.js:73:24)
    at Object.header (/app/node_modules/zigbee-shepherd/lib/components/zcl.js:10:32)
    at dispatchIncomingMsg (/app/node_modules/zigbee-shepherd/lib/components/af.js:631:29)
    at Controller.incomingMsgHandler (/app/node_modules/zigbee-shepherd/lib/components/af.js:714:12)
    at emitOne (events.js:116:13)
    at Controller.emit (events.js:211:7)
    at Object.bridge._areqEventBridge (/app/node_modules/zigbee-shepherd/lib/components/event_bridge.js:15:16)
    at CcZnp.<anonymous> (/app/node_modules/zigbee-shepherd/lib/components/controller.js:98:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@0.1.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the zigbee2mqtt@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-05-28T09_46_37_187Z-debug.log
palitu commented 6 years ago

I'm running in a docker container and i'm not sure where to find the detail log file...

Koenkk commented 6 years ago

Probably you are not running the latest version.

Your log shows at Object.zcl.header (/app/node_modules/zcl-packet/lib/zcl.js:73:24), this is not possible because there is a comment at this line: https://github.com/Koenkk/zcl-packet/blob/master/lib/zcl.js#L73.

To update your docker container:

docker rm -f ZIGBEE2MQTT_CONTAINER_NAME
docker rmi -f ZIGBEE2MQT_IMAGE_NAME

Now run again, this will pull the last version from hub.docker.com.

palitu commented 6 years ago

will give it a go - i thought i had recently done this, but will see what happens now :)

On Tue, May 29, 2018 at 1:47 AM, Koen Kanters notifications@github.com wrote:

Probably you are not running the latest version.

Your log shows at Object.zcl.header (/app/node_modules/zcl-packet/ lib/zcl.js:73:24), this is not possible because there is a comment at this line: https://github.com/Koenkk/zcl-packet/blob/master/lib/zcl.js#L73 .

To update your docker container:

docker rm -f ZIGBEE2MQTT_CONTAINER_NAME docker rmi -f ZIGBEE2MQT_IMAGE_NAME

Now run again, this will pull the last version from hub.docker.com.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/42#issuecomment-392577468, or mute the thread https://github.com/notifications/unsubscribe-auth/AGU9IPmErt_QPbI336-3d_9ge5Pb8gg-ks5t3DgWgaJpZM4T8Q7o .

palitu commented 6 years ago

nope i was wrong, i did not update it correctly.

Looking good now, i can also see more details coming out of the Mi plugs which is good :)

cheers,

On Tue, May 29, 2018 at 10:38 AM, Leigh van der Merwe palitu822@gmail.com wrote:

will give it a go - i thought i had recently done this, but will see what happens now :)

On Tue, May 29, 2018 at 1:47 AM, Koen Kanters notifications@github.com wrote:

Probably you are not running the latest version.

Your log shows at Object.zcl.header (/app/node_modules/zcl-packet/ lib/zcl.js:73:24), this is not possible because there is a comment at this line: https://github.com/Koenkk/zcl-packet/blob/master/lib/zcl.js# L73.

To update your docker container:

docker rm -f ZIGBEE2MQTT_CONTAINER_NAME docker rmi -f ZIGBEE2MQT_IMAGE_NAME

Now run again, this will pull the last version from hub.docker.com.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/42#issuecomment-392577468, or mute the thread https://github.com/notifications/unsubscribe-auth/AGU9IPmErt_QPbI336-3d_9ge5Pb8gg-ks5t3DgWgaJpZM4T8Q7o .

Koenkk commented 6 years ago

Ok good, let me know if you encounter this again.