home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.81k stars 30.51k forks source link

Xiaomi BLE LYWSD03MMC / bindkey not accepted #76898

Closed anico64 closed 1 year ago

anico64 commented 2 years ago

The problem

1-Power on the Xiaomi sensor (not reflashed) 2-Wait time until HA recognize the sensor 3-Wait time until HA show a warning with the request of the bindkey 4-Run Telink flasher. Do the connection. Do the activation to have the bindkey 5-Copy the bindkey created in Telink to HA 6-HA report that the bindkey is wrong

184988161-4d3e3caf-2aa5-4c5d-a06a-6e00319b63ce

What version of Home Assistant Core has the issue?

2022.8.(0,1,2,3,4,5)

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Xiaomi BLE

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

The same hardware was working perfectly with ble_monitor.

Toodrunkforthis commented 2 years ago

I am having the same exact problem.

huishizhao commented 2 years ago

I have the same issue. is anybody find the solution?

Pepeanuts commented 2 years ago

Same here with Xiaomi LYWSD03MMC Home Assistant 2022.8.6 Supervisor 2022.08.5 Operating System 8.5

R0k3z commented 2 years ago

I have the same problem with Xiaomi LYWSD03MMC.

Home Assistant 2022.9.0 Supervisor 2022.08.6

Any ideas how to connect?

probot-home-assistant[bot] commented 2 years ago

xiaomi_ble documentation xiaomi_ble source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @jc2k, @ernst79, mind taking a look at this issue as it has been labeled with an integration (xiaomi_ble) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Jc2k commented 2 years ago

Some context. That device broadcasts infrequently (once every 10 minutes aiui). When testing if a bindkey isn't valid we check against the last data we received. Setting a bindkey doesn't cause a transmission. Leaving the flasher open and connected stops all transmissions.

So basically you set a new bind key but the form validation was checking against the old one.

So I guess: Do the Telink stuff first, write down the bind key, make sure the flasher app is disconnected. wait 10 minutes. Now go into HA and try and add the bind key.

Given you've already started the process to add an bindkey you could try restarting HA to make sure nothing has latched on to an old value.

A future HA release will hopefully be able to set a bindkey without the telink app.

R0k3z commented 2 years ago

Thank You @Jc2k 👍 I will check latter and let You know.

Garywoo commented 2 years ago

So I guess: Do the Telink stuff first, write down the bind key, make sure the flasher app is disconnected. wait 10 minutes. Now go into HA and try and add the bind key.

Given you've already started the process to add an bindkey you could try restarting HA to make sure nothing has latched on to an old value.

I followed these steps, and then HA accepted the bindkey. Thanks @Jc2k
Having this process automated and baked into HA would be amazing!

Jc2k commented 2 years ago

Tell me about it. It's a little fiddly but pretty sure we can do it, if I can find the time!

R0k3z commented 2 years ago

Some context. That device broadcasts infrequently (once every 10 minutes aiui). When testing if a bindkey isn't valid we check against the last data we received. Setting a bindkey doesn't cause a transmission. Leaving the flasher open and connected stops all transmissions.

So basically you set a new bind key but the form validation was checking against the old one.

So I guess: Do the Telink stuff first, write down the bind key, make sure the flasher app is disconnected. wait 10 minutes. Now go into HA and try and add the bind key.

Given you've already started the process to add an bindkey you could try restarting HA to make sure nothing has latched on to an old value.

A future HA release will hopefully be able to set a bindkey without the telink app.

Your solution helped. Now everything works :) Thank You @Jc2k

Pepeanuts commented 2 years ago

So now i've one sensor with bad bindkey but he dont ask me for a new one, what i need to do ? image

As Xiaomi doesnt work for me i use BLE Monitor, i have to delete this integration ?

Jc2k commented 2 years ago

It should prompt you for a new bindkey the first time it sees an encrypted packet it can't decrypt. If it doesn't, it probably didn't pick one up yet.

We've seen that BLEM can interfere with bluez, and that bluez (the Linux bluetooth stack) has tougher stricter requirements of the Bluetooth hardware than BLEM does. So usually it's (1) turn BLEM off, (2) try to reduce interference (extension cable for Bluetooth dongle, no internal Bluetooth, etc) and (3) new dongle.

I had to get a new dongle to get stable Linux Bluetooth that was compatible with BlueZ. My old one would random stop working and in many bizarre ways - sometimes it would only be able to see a single Bluetooth device (my tv). Some of those failure modes are hard to automatically detect as it seems to be working.

Jc2k commented 2 years ago

If you don't want to use the integration, then of course just delete it..

SPEC1AL1ST commented 2 years ago

Same problem on 2022.10.3 Maybe who know how resolve it?

Jc2k commented 2 years ago

If you have the same issue as the OP, then the steps in my first reply should help. If they don't, then it's probably a different issue and you should start another issue instead.

SPEC1AL1ST commented 2 years ago

Some context. That device broadcasts infrequently (once every 10 minutes aiui). When testing if a bindkey isn't valid we check against the last data we received. Setting a bindkey doesn't cause a transmission. Leaving the flasher open and connected stops all transmissions.

So basically you set a new bind key but the form validation was checking against the old one.

So I guess: Do the Telink stuff first, write down the bind key, make sure the flasher app is disconnected. wait 10 minutes. Now go into HA and try and add the bind key.

Given you've already started the process to add an bindkey you could try restarting HA to make sure nothing has latched on to an old value.

A future HA release will hopefully be able to set a bindkey without the telink app.

Thank you! That helped me! Peace sky to all :)

florinpps commented 2 years ago

Hi, those who encounter problems with the bind key, do not readd device in Xiaomi Home, because this bind key will be reset again. Success!

lorcott commented 1 year ago

is it possible to increase the broadcast rate during setup? What is the most frequent period. Then after setup complete change it back to default for power savings?

adorobis commented 1 year ago

Do the Telink stuff first, write down the bind key, make sure the flasher app is disconnected. wait 10 minutes. Now go into HA and try and add the bind key.

Works for me too, thanks!

balucanb commented 1 year ago

@Jc2k We ( Like I am smart enough to do anything) any closer to getting this whole bindkey failing thing fixed in the integration? I am having the same issue, trying your fix from above. Since the flasher tool gives you a different bind key each time you run it and yes I have ran it WAY to many times now, BC...Stoopid. Should I just restart HA, wait and then don't run the flasher tool again and just keep trying to use the one I have until it takes? THX. Update 1 minute later- Yeah that worked. LOL.

Ernst79 commented 1 year ago

is it possible to increase the broadcast rate during setup? What is the most frequent period. Then after setup complete change it back to default for power savings?

No, that isn't possible. the broadcasting interval is hardcoded by Xiaomi on the sensor and is 10 minutes (one message per 10 minutes). Nothing we can do about.

I think we can close this issue. solution is to get the bindkey by adding it to MiHome or TelinkFlasher, after that do not re-add it to MiHome or TelinkFlasher again to avoid creating a new bind key. Wait for more than 10 minutes, preferably 20 minutes. After that, you should be able to set the encryption key in HA.

mikegodin23 commented 1 year ago

is it possible to increase the broadcast rate during setup? What is the most frequent period. Then after setup complete change it back to default for power savings?

No, that isn't possible. the broadcasting interval is hardcoded by Xiaomi on the sensor and is 10 minutes (one message per 10 minutes). Nothing we can do about.

I think we can close this issue. solution is to get the bindkey by adding it to MiHome or TelinkFlasher, after that do not re-add it to MiHome or TelinkFlasher again to avoid creating a new bind key. Wait for more than 10 minutes, preferably 20 minutes. After that, you should be able to set the encryption key in HA.

Thanks. Also worked for me. You just have to be patient...