core icon indicating copy to clipboard operation
core copied to clipboard

Add support of new revision of Mi Temperature and Humidity Monitor Digital Clock LYWSD02MMC

Open PlusPlus-ua opened this issue 2 years ago • 3 comments

The problem

I've just received new Mi Temperature and Humidity Monitor Digital Clock LYWSD02MMC.

I already own one, and it's just perfectly discovered by Xiaomi BLE integration.

New one has definitely new revision, at least of software, but possibly of hardware as well. Xiaomi BLE integration don't want to discover it.

Here is an output of token_extractor for both devices:

   NAME:     Mi Temperature and Humidity Monitor Digital Clock 2
   ID:       blt.4.1d5xxxxxxxx00
   BLE KEY:  19b1c678ab0a8bc3dc7xxxxxxxxxxxxx
   MAC:      A4:C1:38:xx:xx:xx
   TOKEN:    82d6f34d432d190fdxxxxxxx
   MODEL:    miaomiaoce.sensor_ht.t8
   ---------
   NAME:     Mi Temperature and Humidity Monitor Digital Clock
   ID:       blt.3.17xxxxxxxx400
   BLE KEY:  dbe74af28f73bde120cxxxxxxxxxxxxx
   MAC:      E7:2E:01:xx:xx:xx
   TOKEN:    7429439374ecc609exxxxxxx
   MODEL:    miaomiaoce.sensor_ht.t1

I've attached part of my logs related to both devices. I think the root of the problem is a "connectable" state of the new revision.

What version of Home Assistant Core has the issue?

Home Assistant 2023.2.5 Supervisor 2023.01.1 Operating System 9.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Xiaomi BLE

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xiaomi_ble/

Diagnostics information

LYWSD02.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

PlusPlus-ua avatar Feb 22 '23 08:02 PlusPlus-ua

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!

Code owner commands

Code owners of xiaomi_ble can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign xiaomi_ble Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


xiaomi_ble documentation xiaomi_ble source (message by IssueLinks)

home-assistant[bot] avatar Feb 22 '23 08:02 home-assistant[bot]

I can confirm the issue with new version xiaomi Mi Temperature and Humidity Monitor Digital Clock LYWSD02MMC (miaomiaoce.sensor_ht.t8). Is there a way to add support on this version?

Charisketi avatar Feb 28 '23 18:02 Charisketi

I do face the same problems with the LYWSD02MMC.

Similarly, I have no issues with the older versions (LYWSD02)

jumble5 avatar Mar 19 '23 04:03 jumble5

Same problem with model miaomiaoce.sensor_ht.t8.

denysdovhan avatar Apr 01 '23 13:04 denysdovhan

Yes, we can add this device, @PlusPlus-ua can you share the full encryption key with me, such that I can add it? You can send it by mail (e.klamer at gmail) if you don't want to share it here. You can always generate a new one by re-adding it to MiHome.

Note to myself, it uses device type code 0x2542

Ernst79 avatar Apr 01 '23 18:04 Ernst79

thanks @Ernst79 -

would it be possible to also have a way to sync the clock? for now I use this and it works: https://saso5.github.io/LYWSD02-clock-sync/

if it helps, here is mine: Mi token: d7f07347c5d3c549a1fa5d92 Bind key: 18be7b1187a262bcab27d925bd998175

Hope that is what you need, let me know if you need anything else.

AziwACH avatar Apr 01 '23 19:04 AziwACH

I also need some logs of the BLE messages, you can get these by logging the Bluetooth integration (look for the MAC to filter out your sensor.

About syncing the clock. This must be possible, but I'm not familiar with connecting to BLE devices (I have decided to limit my time to passive/active scanning BLE devices only). Perhaps @Jc2k can help, he also made the connection for getting the battery info of the plant sensors, which is the same technique.

Ernst79 avatar Apr 01 '23 20:04 Ernst79

is this what you need? if not let me know, happy to help just need a bit more guidance :)

name: "LYWSD02MMC"
rssi: -61
service_data {
  uuid: "0xFE95"
  data: "0ZB%\000\211\333^8\301\244\010"
}

AziwACH avatar Apr 02 '23 09:04 AziwACH

Hi guys,

Credentials of my device is: NAME: Mi Temperature and Humidity Monitor Digital Clock 2 ID: blt.4.1d5tgaqmkgg00 BLE KEY: 19b1c678ab0a8bc3dc77765f059188d4 MAC: A4:C1:38:0E:FD:78 TOKEN: 82d6f34d432d190fdf770494 MODEL: miaomiaoce.sensor_ht.t8

The log: https://drive.google.com/file/d/1ASqeGTChqpIgfw87n-ey8U8BoyXavSZv/view?usp=sharing

I'm working now on Tuya BLE integration, and I think adding connection option to existing code will need too many changes.

PlusPlus-ua avatar Apr 02 '23 11:04 PlusPlus-ua

@AziwACH You should be able to collect the logs by enabling logging for the Bluetooth integration, see https://www.home-assistant.io/integrations/logger/

# Example configuration.yaml entry
logger:
  default: info
  logs:
    homeassistant.components.bluetooth: debug

After a restart, it will start collecting incoming BLE messages in your Home Assistant logs.

@PlusPlus-ua Your google drive isn't accessible, I have send an access request.

Ernst79 avatar Apr 02 '23 18:04 Ernst79

@Ernst79 - I just sent you the logs by email (using your gmail account you sent earlier). I hope I did it right, please let me know if you need anything else or I need to do something differently.

I was also able to download the logs from @PlusPlus-ua earlier today.

I hope these help. Thanks a lot for your help!

AziwACH avatar Apr 02 '23 19:04 AziwACH

Thanks guys. I have all the info I need.

PR for the parser is ready https://github.com/Bluetooth-Devices/xiaomi-ble/pull/43

Ernst79 avatar Apr 03 '23 07:04 Ernst79

Thanks so much Ernst.

Sorry I am new to this - does this mean that this will be available with the next (or a future) update of ESP Home?

AziwACH avatar Apr 04 '23 20:04 AziwACH

Just to be clear, it will be added to Home Assistant, not ESPHome (ESPHome is just passing through the data to Home Assistant). So it will require a Home assistant update, but first #90806 has to be merged into the development version.

The normal procedure is that new things will be included in a new monthly release. As we missed the deadline for the April release (which is already in beta at this moment), we (you) will have to wait till the May 2023 release (or use the dev version in the meantime).

Ernst79 avatar Apr 04 '23 21:04 Ernst79

got it! thank you fully understood!

Again, appreciate your help and explanations! take care :)

AziwACH avatar Apr 04 '23 21:04 AziwACH