HclX / WyzeSensePy

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

SensorAlarm Payload #1

Closed boolemancer closed 5 years ago

boolemancer commented 5 years ago

I found your blog posts while I was working on solving the same problem, and since I didn't see it here already, I figured I'd share what I found about the SensorAlarm payload for the contact/motion sensor.

8 bytes: big endian timestamp in milliseconds
1 byte:  sensor flags?, 0xa2 for both contact and motion sensor
8 bytes: sensor MAC
1 byte:  sensor type
1 byte:  unknown
1 byte:  remaining battery percentage
1 byte:  unknown, referred to as p1329
1 byte:  unknown
1 byte:  binary sensor state (1: opened/motion detected, 0: closed/no motion detected)
2 bytes: big endian counter for when the sensor is triggered
1 byte:  signal strength, presumably something like absolute value of RSSI (lower is better)

Hope it's helpful.

EDIT: What I had before as 'sensor index' actually looks like the 'sensor type', probably the same value as in the response to dongle_sensor_Random_date_send, where it maps to the dongle_sensor_mode string (DWS3U for contact sensor, PIR3U for the motion sensor)

GeorgeHahn commented 5 years ago

I believe the byte before battery percentage is signal strength (notes). USB traces and in-progress Rust implementation here: GeorgeHahn/stunning-broccoli.

HclX commented 5 years ago

thanks for the information, i've incorporated this into the python code.