custom-components/ble_monitor

Support new Tuya BLE?

pvvx opened this issue · 13 comments

pvvx commented

Some new Tuya devices with BLE transmit data in an encrypted format.

For example TH-05:
When temperature or humidity changes, TH-05 transmits data to BLE advertising encrypted using the Tuya protocol (using additional advertising packages). If there are no changes, a typical BLE advertisement with device identification data is transmitted.
image

LocalTuya can receive Authorization Key and other codes from Cloud (and includes a description of the device)...

pvvx commented

##Advertising packages:

UUID 0xFD50 - TUYA BLE PROTOCOL VERSION 4

type Flag UUID 02 UUID 16 UUID 16 Data
msg 020106 030250fd 141650fd 488040000001b36eb30d64e80a4d9cbc38
adv 020106 030250fd 141650fd 490000080c9c105bc01d9f87

adv - always transmitted.
msg - transmitted when temperature and/or humidity changes.

##Adv contains:

before bond - device pid, after bond - encrypted device_id with login_key and device_id

##Packet bytes, except for standard identifiers, are formed as follows:

[7] pid_len+7
[11,12] Frame Control: bound_flag |0x08, DEVICE_SHARED |0x04, connect request bit |0x02
[13] pid_type
[14] pid_len
[15...] code

Clarification https://github.com/tuya/tuya-ble-sdk/blob/main/sdk/src/tuya_ble_main.c#L453

Thanks for the info. I'm afraid this will be difficult (for me) to add. Will give it a try later.

I assume temperature and humidity are in [15...] code, after decryption.

pvvx commented

Another thermometer with Tuya BLE - MHO-C122 (2AWMOMHOC122).

fcc.report

@pvvx have you had any luck?

Any luck with getting data out of the TH05?

They're now available very cheap on the AliExpress Choice Day Sales - which is why I now own one.

Following. I bought some of these thinking they were the same as the old ones I have that work just fine with BLE sensor in HA proxied through ESPHome. I didn't see they were new models :(

pvvx commented

For the "THB2" sensor, the only solution so far is to reflash it in the PhyPlusKit program, using the files from https://pvvx.github.io/THB2/
Test firmware files for working in BTHome format.
image
This is not a full version - only temperature and humidity are transmitted every 2.5 seconds.
Updates are possible in the future.

@pvvx Do you have a functional download link for the PhyPlusKit software? I came across a link, but unfortunately, it's no longer operational!

pvvx commented

https://github.com/pvvx/PHY62x2/tree/master/PhyPlusKit
I have all the SDKs from PHY, but they can be found by searching on github.
The test firmware is based on sources from https://github.com/biemster/st17h66_FindMy
They had previously worked on optimizing consumption and these developments were used.

@pvvx Thank you very much for the resources. Keep up the great work!

great work, thanks!!

Custom firmware for Tuya devices on the PHY622x2 chipset to work in the BTHomeV2 format.

image

This is great! Thank you!
When flashed, is the device openly accessible? I would like to skip esphome altogether and just read the sensor data from an ESP32/Arduino (not EspHome).