Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Xiaomi reset on long press #1060

Merged
merged 1 commit into from
Mar 13, 2020
Merged

Conversation

qm3ster
Copy link
Contributor

@qm3ster qm3ster commented Mar 12, 2020

Respond to long press like stock hub does.

Currently added behavior only to devices I own, but most likely applies
to "without neutral" variants as well, since those lie in-between battery
and "with neutral" devices.

Remaining questions:

  1. This does not prevent kicking from the network, but some crazy people might still want it configurable. For this options (device specific configuration) needs to be passed to onEvent or I need a way to obtain it using the passed in device. Or, does this need to be dynamically configurable via mqtt?
  2. Maybe I should blindly add this to more devices, otherwise we need testers with device / sniffers with device and hub / someone to send me a device. Shouldn't be any harm.
  3. It's not clear what the contents of the message actually are, and when they might change.

[0xaa, 0x10, 0x05, 0x41, 0x87, 0x01, 0x01, 0x10, 0x00]
On wired devices in the report, the last octet is always 0, and the "counter" octet (after 0x84) is always 1.
On wireless buttons, the last octet was 1 (like in the write response from hub) and the counter was incremented on the device side, sometimes by 2.
The write response always has 0x47 instead of 0x87, so that bit is moved, always 1 in the last octet, and is generally identical for all devices tested, just merrily incrementing the counter (IIRC globally, for any device it sends this to). Not incrementing the counter didn't interfere with the functionality of this PR, even if the response value was less than that in the report, so its purpose remains unknown.

It might be worthwhile to mess around more with what we send and see what works, but currently the goal is achieved.
I tested this with CC2531 to not disturb my production networks.

Respond to long press like stock hub does.
Currently added behavior only to devices I own, but most likely applies
to "without neutral" variants as well, since those lie inbetween battery
and "with neutral" devices.

Tested, really prevents escape.
@qm3ster
Copy link
Contributor Author

qm3ster commented Mar 12, 2020

(eslint)

@Koenkk
Copy link
Owner

Koenkk commented Mar 13, 2020

спасибо!

@Koenkk Koenkk merged commit 2f97a35 into Koenkk:master Mar 13, 2020
Koenkk pushed a commit that referenced this pull request Mar 18, 2020
After seeing #1060 tested with QBKG03LM and QBKG04LM, and it works just fine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants