Maxmudjon / homebridge-mijia

Mijia plugin for homebridge
49 stars 7 forks source link

Error with sensor motion #31

Open fjlopezandreu opened 7 years ago

fjlopezandreu commented 7 years ago

I have a raspberry pi 2 with the latest version of raspbian. I installed homebridge and I added the plugin homebridge-mijia.

Everything goes perfectly until the motion sensor is activated, the following error occurs:

/opt/node/lib/node_modules/homebridge-mijia/lib/MiJiaPlatform.js:254 this.factory.setMotion(gatewaySid, deviceSid, motionDetected, battery1, battery2); ^

ReferenceError: battery2 is not defined at MotionParser.parse (/opt/node/lib/node_modules/homebridge-mijia/lib/MiJiaPlatform.js:254:75) at MiJiaPlatform.parseMessage (/opt/node/lib/node_modules/homebridge-mijia/lib/MiJiaPlatform.js:186:27) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:550:8)

According to the application my gateway is lumi.gateway.v3.

fjlopezandreu commented 7 years ago

I have debugged the MiJiaPlatform.js file and have noticed that the gateway only sends heartbeat messages. When a message of type read_ack is never sent, the variable battery2 is never initialized and therefore the error in the parsers of the accessories occurs.