Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

Did you try to move the sensor closer?. Perhaps enabling the logger to show all log messages will give more clues.

Hi,
I just updated my MiHome app to version 5.2.0 and the firmware on an newly bought LYWSD03MMC to 0109

now binding the device to the app does not include the “bind_key”. Looks like they changed the protocol.

Instead I found a Bind command with these parameters in the request:

PassportDeviceId=86444235B5FED29E; 
serviceToken=YTQZ1ezf9LPfOTTRr73+7OLH6zb9Ur2kHkugDrmE2qjjSoWQn7IYEto7yHbJaaCBgtgV/KjMbZNG5prpjX/3OUR9Fe4Q/gRRpDX4eR1ZsT0hnViZuWfWUKAckNZedLGPhjL7jZeoZE2xg6/lsJkVnk95UeMK2BW4r/jjpMnj/kI=; 
youpin_sessionid=1600282433809_7627E540-3D54-40F2-97FC-B82D6AF426F4_3087744179; 
mUserId=kvxpSDePjDl1PjPOuQKsAGF6TLSAAWxv1jKQqtLCdxw%3D; 
miotstore_serviceToken=WpWK8/PhuZkGcUIMBMtek8ISuznt496xjUMEQtpAXNyoSZgcbZLM+v2fZRrvatWKUPNf2zbWMy0HP8x74cy2uTz+v8n/sZbp1/Ydh9cNW6g+3pPfuyBcAFrqKIko6J/LXFTlahWCIqGzcw6CaUJDXw==

and this response:

xc9P1uSIZiTubQbr744RdNEha7XSd7lUiIpC6ceg9h27Q48xwupn

It is 52 characters and not pure HEX like the previously used 32 long HEX encryption key.

Anybody knows whether it will work with this key or do I need to find the 32 long HEX key in some other way

I did, it’s right next to the PC now, within a couple inches of the wifi/bluetooth card.
I enabled the logger, this is what I see, seems to be the same logged events over and over from what I can tell, so I hope I copied enough of it.

2020-09-16 15:18:13 DEBUG (Thread-99) [custom_components.mitemp_bt.sensor] HCIdump thread: Connected
2020-09-16 15:18:13 DEBUG (Thread-99) [custom_components.mitemp_bt.sensor] HCIdump thread: start main event_loop
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] update_ble called
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] Discovering Bluetooth LE devices
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] Time to analyze...
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] Getting data from HCIdump thread
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] HCIdump thread: joining
2020-09-16 15:19:13 DEBUG (Thread-99) [custom_components.mitemp_bt.sensor] HCIdump thread: main event_loop stopped, finishing
2020-09-16 15:19:13 DEBUG (Thread-99) [custom_components.mitemp_bt.sensor] HCIdump thread: Run finished
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] HCIdump thread: joined
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] Spawning HCIdump thread(s).
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] HCIdump thread: Init
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] HCIdump thread: Init finished
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] Starting HCIdump thread for hci0
2020-09-16 15:19:13 DEBUG (Thread-100) [custom_components.mitemp_bt.sensor] HCIdump thread: Run
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] HCIdump threads count = 1
2020-09-16 15:19:13 DEBUG (Thread-100) [custom_components.mitemp_bt.sensor] HCIdump thread: Connection
2020-09-16 15:19:13 DEBUG (Thread-100) [custom_components.mitemp_bt.sensor] HCIdump thread: Connected
2020-09-16 15:19:13 DEBUG (Thread-100) [custom_components.mitemp_bt.sensor] HCIdump thread: start main event_loop
2020-09-16 15:19:13 DEBUG (SyncWorker_23) [custom_components.mitemp_bt.sensor] Finished. Parsed: 4 hci events, 0 xiaomi devices.

Any clues in there? As far as I can tell, it’s just not finding any Xiaomi devices, but not complaining about anything either.

Hi,

What is the sensor type of your Xiami thermometer?

Se the supported sensor types her:

Try maybe to add:

report_unknown: true

in your configuration

Hi,
Trying to use the Telink Flasher to get the bind key from my Iphone
but it just writes “searching for devices” in the log and nothing more happens.

anybody managed to get it working from an Iphone?

Thanks :slight_smile:

My sensor is the LYWSD03MMC, little square one.
Doesn’t look like much new in the logs.

2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] Starting
2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] Spawning HCIdump thread(s).
2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] HCIdump thread: Init
2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] HCIdump thread: Init finished
2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] Starting HCIdump thread for hci0
2020-09-16 16:44:18 DEBUG (Thread-4) [custom_components.mitemp_bt.sensor] HCIdump thread: Run
2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] HCIdump threads count = 1
2020-09-16 16:44:18 INFO (SyncWorker_12) [custom_components.mitemp_bt.sensor] Attention! Option report_unknown is enabled, be ready for a huge output...
2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] 1 encryptors mac:key pairs loaded.
2020-09-16 16:44:18 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] 0 whitelist item(s) loaded.
2020-09-16 16:44:18 DEBUG (Thread-4) [custom_components.mitemp_bt.sensor] HCIdump thread: Connection
2020-09-16 16:44:18 DEBUG (Thread-4) [custom_components.mitemp_bt.sensor] HCIdump thread: Connected
2020-09-16 16:44:18 DEBUG (Thread-4) [custom_components.mitemp_bt.sensor] HCIdump thread: start main event_loop
2020-09-16 16:44:19 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] update_ble called
2020-09-16 16:44:19 DEBUG (SyncWorker_12) [custom_components.mitemp_bt.sensor] First run, skip parsing.
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] update_ble called
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] Discovering Bluetooth LE devices
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] Time to analyze...
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] Getting data from HCIdump thread
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] HCIdump thread: joining
2020-09-16 16:45:19 DEBUG (Thread-4) [custom_components.mitemp_bt.sensor] HCIdump thread: main event_loop stopped, finishing
2020-09-16 16:45:19 DEBUG (Thread-4) [custom_components.mitemp_bt.sensor] HCIdump thread: Run finished
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] HCIdump thread: joined
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] Spawning HCIdump thread(s).
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] HCIdump thread: Init
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] HCIdump thread: Init finished
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] Starting HCIdump thread for hci0
2020-09-16 16:45:19 DEBUG (Thread-11) [custom_components.mitemp_bt.sensor] HCIdump thread: Run
2020-09-16 16:45:19 DEBUG (Thread-11) [custom_components.mitemp_bt.sensor] HCIdump thread: Connection
2020-09-16 16:45:19 DEBUG (Thread-11) [custom_components.mitemp_bt.sensor] HCIdump thread: Connected
2020-09-16 16:45:19 DEBUG (Thread-11) [custom_components.mitemp_bt.sensor] HCIdump thread: start main event_loop
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] HCIdump threads count = 1
2020-09-16 16:45:19 DEBUG (SyncWorker_9) [custom_components.mitemp_bt.sensor] Finished. Parsed: 3 hci events, 0 xiaomi devices.

Below are some things I did and learned while working with my LYWSD03MMC sensors:

  • Using the Mi app, pair a sensor (the sensor is right next to my mobile phone), get the bluetooth mac address, configure to use Fahrenheit instead of Celcius then delete the paired sensor. (I don’t have to delete it but I do).
  • Using the Telink Flasher, [Connect] to the Mi-app-paired sensor then [Do Activate] to get the bind-key.
  • When pairing a sensor, I make sure that all already-paired sensors are away from my mobile app. This is because the Mi app might inadvertently pair with the already-paired sensors. When this happens the bind key is regenerated and the previous bind key is no longer valid.
  • When working with the Mi app and Telink Flasher, make sure that the battery in the sensor is good. If the Mi app cannot pair with (or the Telink Flasher cannot connect to) the sensor right next to my mobile phone then most likely I needed to put a fresher battery.
  • Removing the battery in the sensor invalidates the bind key. Make sure to get the new bind key after replacing the battery.

I hope the above information helps.

Thanks for your input.
Have you experience using the Telink bind function from an Iphone?
I am afraid it only works with android

The Telink Flasher is a website so I don’t understand why it would not work on iPhone.

I know but it is accessing the Bluetooth chip it’s not just a pure website but depends on the hardware and the restrictions to access these

So I guess you haven’t tried that.

I’ll try to ask the developer behind the flasher and hope he can provide a clear answer to that.

Thanks anyway for your effort :slight_smile:

great sensor, just installed it, and after a few minutes all 3 of my new LYWSD02 clocks are recognized and readable (prior they were connected to the Mi Home app)

I can no longer decrypt the bind key on iOS 14. Stream sniffer doesn´t show me the bind_key value (I am able to find bltbind, there are “hash” and “signature” strings in the decoded response but not bind_key) CA is installed and trusted), and the Telink web app just searches for devices indefinitely. I made the mistake of pairing one of my three LYs with the Mi Home app and now I can´t get it back to work with HA. Any tips?

2 Likes

Same here. Searching indefinitely on ios 14.

1 Like

The tool developers confirmed that i doesn’t work from iPhone (IOS) but from Android or Chrome running on newer pc/laptop.

it works for me now :slight_smile:

Please let men know if you have any further questions

Tried the Telink web app with MS Edge on my Macbook. I’m able to connect and generate a bind key, but the integration doesn’t do anything after that. 20 minutes and counting. I DID have it working before I accidentally paired my LYWSD03 to the Mi app.

Also, I find it odd that all of my LY MAC addresses changed. and appear completely random now (they began with the same three or four pairs of characters before).

EDIT: how do I display real MAC addresses? The random ones I wrote about are probably some kind of auto-generated security obfuscation, why is why it doesn’t work. When I scan with bluetoothctl on the Pi that runs HASS, I get the old addresses, but I can’t use them in any way as I have three LYs and I need to pair MAC addresses with bind keys.

EDIT 2: I had to do it from Windows to get real MAC addresses. One of the cases where Apple security gets in the way. All three of my LYs work properly again.

If I got Hassio installed on an old PC - can I still use these on my home assistant setup or do I need some sort of bluetooth device to read the temps or will it link just installing on the Mijia app.

The instructions in the faq are now updated to only use the Telink website with android and Windows.

Ok, I figured out the problem. It’s the Intel AX200 Bluetooth. I borrowed an Asus USB-BT400 from my main machine, and it found the LYWSD03MMC sensor right away and started showing temp and humidity within a few minutes. Bluetoothctl with the AX200 could see the sensor, but no devices/entities ever showed up. Anyone know if there’s any way to make the AX200 work?

Hi, I’m trying to connect a number (5, soon 9) of LYWSD03MMC to Home Assistant.
I have installed the custom component through HACS and restarted multiple times, the component runs, but no new devices show up even hours later. I turned up debugging and see that the component is receiving BLE beacons, but it always says “0 xiaomi”.

Do I need to flash custom firmware to the LYWSD03MMC to enable the value broadcasting in the BLE advertisements? Or should it work out of the box?

Also is there any way to check that the encryptors are set up right? I got them through the TelinkFlasher, but I’m not sure whether the Bind Key changes for example when adding the devices to the Xiaomi Home app?

(Update: Looks like the bind key is regenerated every time, damn. Is there any way to use this device with the Mi app and HA at the same time? Do I have to sniff the key?)

Yes, if you want to use with both Hassio and Mi Home app, then you need to use the bind key generated by the Mi App.
You can get it by sniffing the network traffic, example by Stream app, export the .har file, send it to a computer, open the file in Chrome IE or other network browser and search for bind_key