HclX / WyzeSensePy

A python script communicating with WyzeSense gateway
MIT License
91 stars 15 forks source link

Potential parsing issue of data received from motion sensor #12

Open elyorkhakimov opened 4 years ago

elyorkhakimov commented 4 years ago

First of all, huge thanks for the work you've done, reverse engineering the WyzeSense protocol !

I'm actually using gosense library, but also used this package, and appear to be running into this issue. When Motion sensor detect motion, bridge sees 62 byte frame, and parsing it shows "State: 1". 40 seconds later it receives another frame with 62 bytes, and parsing it shows "state: 0". All good.

However totally unsolicited, at some point after that second message, Wyze bridge receives one more message which is only 39 bytes long.

2020-06-19T19:33:30.561536251Z DEBU[0578] readRawHid: 62 bytes: [ 55aa53193500000172ce123b360ea2373741313742414202010053064655aa531d1900000172ce123b39a2373741313742414202176400010100531606b5 ] ,2020-06-19T19:34:10.558263651Z DEBU[0618] readRawHid: 62 bytes: [ 55aa53193500000172ce12d0230ea237374131374241420200005406c855aa531d1900000172ce12d026a237374131374241420217640001000054170738 ] ,2020-06-19T19:35:30.557162901Z DEBU[0698] readRawHid: 39 bytes: [ 55aa53231900000172ce13f9f7ab37374131374241420200000100000100000100000117000776 ]

I see other threads that might be indicating similar issue?

raetha commented 4 years ago

@elyorkhakimov PR #14 will work around this issue. It's now been included in the forks that both Kevin Vincent and I use for our projects.

Unfortunately we don't know for sure what the 39 byte packet is, though I have anecdotal suspicions it represents a low battery. It would be great if someone knew how to parse the packet to at least get the MAC for the sensor from it. We could then do some testing to see if it being triggered correlates with a low battery. I'm hoping someone in the community that understands this side of things better will help with parsing the packet.

elyorkhakimov commented 4 years ago

thank you @raetha for the follow up. I have been working around this issue in ha-gosenseapp by filtering out messages that do not parse. I don't believe this is a low battery message, as all of the sensors in my setup are more or less new, and in fact report 92% of battery state or more.