HclX / WyzeSensePy

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

Sensor with no MAC ID #6

Open WayneManion opened 4 years ago

WayneManion commented 4 years ago

I've been playing with the sample.py script. I have a whole bunch of sensors, all but one of which reliably generate output like:

[2019-10-14 17:09:08][77835FCF]StateEvent: sensor_type=switch, state=open, battery=94, signal=85
[2019-10-14 17:09:10][77835FCF]StateEvent: sensor_type=switch, state=close, battery=94, signal=94

I keep getting this output when one of my sensors changes state:

[2019-10-14 17:09:08][]StateEvent: sensor_type=switch, state=open, battery=94, signal=85

When I change line 32 in sample.py from:

s = "[%s][%s]" % (e.Timestamp.strftime("%Y-%m-%d %H:%M:%S"), e.MAC)

to:

s = "[%s][%r]" % (e.Timestamp.strftime("%Y-%m-%d %H:%M:%S"), e.MAC)

The data in e.MAC is shown on screen as "u\x00\x00\x00\x00\x00\x00\x00\x00". I'm not really sure what this means. I changed the code in the unpair function (because it won't run unless given precisely eight digits) to just send "\x00\x00\x00\x00\x00\x00\x00\x00" to the hub and that seems to unpair the device. I can pair it up again just fine, but it still has that empty/nonsense MAC ID.

This misbehaving (?) sensor may have something to do with the issue I created earlier.

WayneManion commented 4 years ago

I hacked up the code in gateway.py a little bit to get a better look at where things were getting stuck. I also commented out the lines 373 & 374 of gateway.py so the script doesn't just crash.

It seems like it takes a long time (over a minute) to perform the instruction (line 370):

result = e.wait(timeout)

inside the _DoCommand() function when command 5330 (payload 15) is issued.

Another quirk is that the result of command 532E is 21 sensors (the correct number), but after 5330 finally finishes executing, it gves a list with either 19 or 20 sensors in it. The number of sensors seems to bounce randomly between 19 and 20.