zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Xiaomi Motion Sensor RTCGQ11LM not reporting occupancy:true the second (like#1498)

Open e-t-h opened this issue 7 years ago • 141 comments

Bug Report

I have the same issue like described in the closed issue #1498: sensors don't report occupancy:true. I have two RTCGQ11LM sensors, ran for a long time at an Aqara Hub, without any issues. Since I am working with zigbee2mqtt I've noticed that they shows the same behavior @zerofruchtshake desribed in issue #1498: the occupancy value is not set properly. I am currently not able to get a message with "true".

What happened

Two sensors: Sensor 1 (friendly name Bew_unten) is hardware modified like discribed in the documentation to shorten the time the sensor ignores any movements.

Sensor 2 (friendly name Bew_oben) is not modified. Both have the same issue.

What did you expect to happen

sensors value "occupancy" should be set to "true"

How to reproduce it (minimal and precise)

It happens every time with every sensor; sensors were resetted,

Debug Info

zigbee2mqtt version: 1.6.0, CC253X firmware version:20190608

I've collect some debug messages with the option DEBUG=zigbee-shepherd*-option, might be that helps? Currently I am not able to sniff with a second CC253x..

sensor 1

zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg +114ms zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: {"groupid":0,"clusterid":1024,"srcaddr":33408,"srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"linkquality":34,"securityuse":0,"timestamp":8829962,"transseqnumber":0,"len":8,"data":{"0":24,"1":47,"2":10,"3":0,"4":0,"5":33,"6":18,"7":0},"zclMsg":{"frameCntl":{"frameType":0,"manufSpec":0,"direction":1,"disDefaultRsp":1},"manufCode":0,"seqNum":47,"cmdId":"report","payload":[{"attrId":0,"dataType":33,"attrData":18}]}} +92ms zigbee2mqtt:debug 11/4/2019, 12:27:34 PM Received zigbee message of type 'attReport' with data '{"cid":"msIlluminanceMeasurement","data":{"measuredValue":18}}' of device 'lumi.sensor_motion.aq2' (0x00158d0002b48ee2) of endpoint 1 zigbee2mqtt:info 11/4/2019, 12:27:34 PM MQTT publish: topic 'zigbee2mqtt/Bew_oben', payload '{"illuminance":18,"linkquality":34,"occupancy":false,"battery":100,"voltage":3035}' zigbee2mqtt:debug 11/4/2019, 12:27:34 PM Received zigbee message of type 'devChange' with data '{"cid":"msIlluminanceMeasurement","data":{"measuredValue":18}}' of device 'lumi.sensor_motion.aq2' (0x00158d0002b48ee2) of endpoint 1 zigbee-shepherd:msgHdlr IND <-- ZDO:srcRtgInd +31ms

sensor 2

zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg +8ms zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: {"groupid":0,"clusterid":1024,"srcaddr":40372,"srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"linkquality":31,"securityuse":0,"timestamp":8830101,"transseqnumber":0,"len":8,"data":{"0":24,"1":24,"2":10,"3":0,"4":0,"5":33,"6":44,"7":0},"zclMsg":{"frameCntl":{"frameType":0,"manufSpec":0,"direction":1,"disDefaultRsp":1},"manufCode":0,"seqNum":24,"cmdId":"report","payload":[{"attrId":0,"dataType":33,"attrData":44}]}} +9ms zigbee2mqtt:debug 11/4/2019, 12:27:34 PM Received zigbee message of type 'attReport' with data '{"cid":"msIlluminanceMeasurement","data":{"measuredValue":44}}' of device 'lumi.sensor_motion.aq2' (0x00158d0002b42bd0) of endpoint 1 zigbee2mqtt:info 11/4/2019, 12:27:34 PM MQTT publish: topic 'zigbee2mqtt/Bew_unten', payload '{"illuminance":44,"linkquality":31,"battery":100,"voltage":3035,"occupancy":false}' zigbee2mqtt:debug 11/4/2019, 12:27:34 PM Received zigbee message of type 'devChange' with data '{"cid":"msIlluminanceMeasurement","data":{"measuredValue":44}}' of device 'lumi.sensor_motion.aq2' (0x00158d0002b42bd0) of endpoint 1

Any ideas? What can I additionaly provide? Does this debug output help to determine what the stick have received? I assume that the data item in the incoming message stores this information? Am I able to figure out how the software translate the data into the payload (if so, where I can find it)?

data 1 {"0":24,"1":47,"2":10,"3":0,"4":0,"5":33,"6":18,"7":0} data 2 {"0":24,"1":24,"2":10,"3":0,"4":0,"5":33,"6":44,"7":0} payload 1 {"illuminance":18,"linkquality":34,"occupancy":false,"battery":100,"voltage":3035}' payload 2 {"illuminance":44,"linkquality":31,"battery":100,"voltage":3035,"occupancy":false}

Sincerly..

e-t-h avatar Nov 04 '19 17:11 e-t-h

In the log I see that only the illuminance level is reported and no occupancy, can you check again with the xiaomi hub if they work there?

Koenkk avatar Nov 05 '19 15:11 Koenkk

I've just did it, and it works. I get the message "Motion detected, Illumination is: xx Lux.

Today I've observed the sensors and found messages with occupancy = true. Here a corresponding log:

zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: {"groupid":0,"clusterid":1024,"srcaddr":40372,"srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"linkquality":105,"securityuse":0,"timestamp":5300358,"transseqnumber":0,"len":8,"data":{"0":24,"1":11,"2":10,"3":0,"4":0,"5":33,"6":36,"7":0},"zclMsg":{"frameCntl":{"frameType":0,"manufSpec":0,"direction":1,"disDefaultRsp":1},"manufCode":0,"seqNum":11,"cmdId":"report","payload":[{"attrId":0,"dataType":33,"attrData":36}]}} +9ms zigbee2mqtt:debug 11/4/2019, 10:13:34 PM Received zigbee message of type 'attReport' with data '{"cid":"msIlluminanceMeasurement","data":{"measuredValue":36}}' of device 'lumi.sensor_motion.aq2' (0x00158d0002b42bd0) of endpoint 1 zigbee2mqtt:info 11/4/2019, 10:13:34 PM MQTT publish: topic 'zigbee2mqtt/Bew_unten', payload '{"illuminance":36,"linkquality":105,"battery":100,"voltage":3035,"occupancy":true}' zigbee2mqtt:debug 11/4/2019, 10:13:34 PM Received zigbee message of type 'devChange' with data '{"cid":"msIlluminanceMeasurement","data":{"measuredValue":36}}' of device 'lumi.sensor_motion.aq2' (0x00158d0002b42bd0) of endpoint 1 zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: {"groupid":0,"clusterid":1030,"srcaddr":40372,"srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"linkquality":105,"securityuse":0,"timestamp":5300370,"transseqnumber":0,"len":7,"data":{"type":"Buffer","data":[24,12,10,0,0,24,1]}} +22ms

Where can you see that no occupancy is reported? For me it looks quite similar..

Thx

e-t-h avatar Nov 05 '19 17:11 e-t-h

If occupancy is reported you will find msOccupancySensing in the log, you should find it above the log you currently posted (otherwise occupancy won't be true).

Koenkk avatar Nov 06 '19 09:11 Koenkk

I just posted #2364.

I wanted to let you know that I once again was able to get the faulty sensor to work again. I re-paired it several times and suddenly it started working again.

Normally it works for a few weeks or months and then it starts failing again. The procedure to get it cooperate again is not exactly reproducible and simply restarting zigbee2mqtt can make it fail again.

guardiande avatar Nov 18 '19 20:11 guardiande

I have the same problem

Sepultura22 avatar Nov 20 '19 13:11 Sepultura22

Now we are three of us ;-) In the meanwhile I've tested both of my sensors at the Xiaomi Hub with no errors. The sensors reports the illuminance from time to time and also every event of movement correctly. Next step in my case is to update the Zigbee2MQTT software to the newest version, reconnect the sensors to it and test again (with the knowledge of what guardiande wrote). I'll be back ;-)

e-t-h avatar Nov 20 '19 13:11 e-t-h

I have the latest version of [email protected] and the latest firmware in CC2531 (20190608), but the problem persists.

Sepultura22 avatar Nov 21 '19 15:11 Sepultura22

To further debug this issue, could you sniff the traffic while the sensor should detect occupancy when connected with zigbee2mqtt (https://www.zigbee2mqtt.io/how_tos/how_to_sniff_zigbee_traffic.html)?

Koenkk avatar Nov 21 '19 15:11 Koenkk

I suppose I need another CC2531? I will order one and come back with the results. It's gonna take some time.

e-t-h avatar Nov 21 '19 15:11 e-t-h

Yes you need another one

Koenkk avatar Nov 21 '19 16:11 Koenkk

I will wait patiently for e-t-h to do the test, because I don't have another dongle either. :)

Sepultura22 avatar Nov 21 '19 17:11 Sepultura22

Hi Koenkk, I've got my second receiver, flashed it, installed Wireshark and ZBOSS on my Windows Laptop like described in your doc. I can start the system, the green LED is flashing. But I don't see any traffic although there is something. I am not sure which Zigbee-page I have to select, I've tried all of them. Also the hex value after the page select box... Are there known pitfalls?

e-t-h avatar Dec 16 '19 14:12 e-t-h

Okay, thank you for your support, surprisingly it is now working! Please ignore the posting before ;-)

e-t-h avatar Dec 16 '19 15:12 e-t-h

Hi Koenkk, amusingly the sensors do now what I expect they have to do. Did you change anything in the software? I've done what you've suggested regarding the sniffing and additionally I've updated the zigbee2mqtt to the latest version 1.8.0. After that I've begun the tests. Everything works well with the motion sensors now. They report the status "occupancy=true" and after a time with no movement the status is set to "false".

Might be you've changed something? Or: I've been running the sensors together with the XIAOMI-hub meanwhile I've been waiting for the USB stick. Is it possible that an update of the firmware of the sensor have happened in this period? I'll observe the behavior and will report here if something different happens.

Is there anything I can read to be able to understand the data packets I receive with my brand new sniffer what you can recommend? I would appreciate any advice.

By the way, is it possible to initiate a transmit of the illumination value by sending a request from the stick?

Last but not least: Thank you for your work!

Ekkehard

e-t-h avatar Dec 17 '19 10:12 e-t-h

Hi @e-t-h,

I'm afraid that you most likely experience the same symptoms in the future again. I'm having this problem for many months now and the problem normally persists only for a week or something and then the sensor stops working again.

Sometimes it happened right after just restarting z2m and I think it also happened during normal operation. Then it takes me many re-pairing to get it work again and then it works stable for some time.

It could be that the behaviour is more likely to happen if the sensor connects via a router but I'm not sure.

Jan

guardiande avatar Dec 17 '19 12:12 guardiande

Hi Jan, I am also not very convinced that the issue simply disappeared. Thats why I've asked for hints how to work with the sniffing tool. Unfortunately I'm not experienced with Zigbee messages. I'll observe the behavior and when it'll changes I'll come back to this post. Currently I don't see much more opportunities. I'm waiting for the reply of Koenkk also. Did you upgrade to 1.8.0? This update is only just two days old. If not it would be helpful if you can check if it includes the solution. I had the 1.6.0 running when the issue appeared.

Ekkehard

e-t-h avatar Dec 17 '19 14:12 e-t-h

Xiaomi devices can drop off the network when the linkquality is low, this can be improved: https://www.zigbee2mqtt.io/how_tos/how_to_improve_network_range.html

Koenkk avatar Dec 17 '19 18:12 Koenkk

Hi @Koenkk,

The sensors don't completely drop off the network since they're still reporting luminance and battery levels every hour our so (as you already saw from analyzing the logs a few posts above).

Jan

guardiande avatar Dec 17 '19 18:12 guardiande

@guardiande that's even more interesting. When this happens, could you sniff the zigbee traffic when you expect occupancy being detected? In this way we can determine if it's an issue of zigbee2mqtt or the sensor itself. https://www.zigbee2mqtt.io/how_tos/how_to_sniff_zigbee_traffic.html

Koenkk avatar Dec 17 '19 18:12 Koenkk

@Koenkk I just got myself a second CC2530 for that but (un-)fortunately it's working now. Will have to way for the next failure :)

guardiande avatar Dec 17 '19 18:12 guardiande