PlusPlus-ua / ha_tuya_ble

Home Assistant support for Tuya BLE devices
MIT License
191 stars 137 forks source link

TH05 temperature sensor #37

Open ahmedhoumeci opened 1 year ago

ahmedhoumeci commented 1 year ago

H Screenshot_20230626_075058_Samsung Internet ello, there is a way to integrate a tuya BLE temperature sensor? Thank you

ernstmosch commented 1 year ago

Have the same device - want the same - and am willing to contribute. But Unfortunately i am not a "Full Coder" would be happy providing data or do testing. Thank everybody in advance.

PlusPlus-ua commented 1 year ago

Hi, does integration discover the device? If no, most of all, the device is not BLE but Bluetooth Mesh.

ahmedhoumeci commented 1 year ago

Hi, sometimes it discovers it but then when I go to configure it, I have error.

PlusPlus-ua commented 1 year ago

It gives a hope. Try to move the device closer to your Bluetooth adapter and connect it to HA using the integration. It must connect and expose one hidden entity "signal strength". If connections fail, the debug log will be required to understand the root of the problem.

ahmedhoumeci commented 1 year ago

The device is less than 10 cm from the raspberry. As soon as it reappears, I'll forward you the logs

PlusPlus-ua commented 1 year ago

One important thing, if your device is bound to your Tuya BLE hub - unbind it. The hub keeps the device always connected, and it's preventing any attempts to connect it.

ahmedhoumeci commented 1 year ago

Thanks for the info, but i don't use Tuya BLE hub.

fliespl commented 1 year ago

@PlusPlus-ua can you share steps I can do to help this integration? Already have device, I am familiar with Tuya API, have developer tokens, cause have been debugging zigbee stuff and programming is my main occupation.

One small issue - I am using esphome as bluetooth adapters and not one inside HA - will this work?

cypherbits commented 1 year ago

Tried to add support for this device on the code locally but no luck.

Javitel commented 1 year ago

I played a bit with a local copy of the code and I progressed from "no pending device found" to "invalid config" or something like that. I believe its possible but taking a look at the code for a few hours is not enough for me to have all the execution under control.

Javitel commented 1 year ago

for more info, I registered it into my tuya development account and I found product main code (sorry if my terms are not 100% accurate) is the same as the soil sensor...? "wsdcg" from there I had more numbers but I was not able to find exactly what matches with what and where I need to add extra nodes or functions

image

cypherbits commented 1 year ago

The product_category is the same from the soil sensor: "wsdcg". The product_id is different: "vyfoip9h". I added everything on the "I think right" places but not working...

ahmedhoumeci commented 1 year ago

Screenshot_20230707_170313_Home Assistant Now, tuya ble found it, but I have this error.

In tuya cloud (smartlife app) the sensor exist.

cypherbits commented 1 year ago

It seems it is interfering with default xiaomi_ble somehow on autodiscovery: Debug logs:

2023-07-10 20:01:40.635 DEBUG (MainThread) [aioesphomeapi.connection] esp32s3-test-ble-custom @ 192.168.0.130: Got message of type <class 'api_pb2.BluetoothLERawAdvertisementsResponse'>: advertisements {
address: 242044213326837
rssi: -80
data: "\002\001\006\003\002P\375\017\026P\375A\000\000\010vyfoip9h\027\377\320\007\000\000\001\004\017\300j\201\334\277\360\316AC\013\001\324\177\263|\005\tdemo"
}
2023-07-10 20:01:40.636 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] esp32s3-test-ble-custom (34:85:18:8f:1a:a4) [connectable]: DC:23:4F:5A:F3:F5 AdvertisementData(local_name='demo', manufacturer_data={2000: b'\x00\x00\x01\x04\x0f\xc0j\x81\xdc\xbf\xf0\xceAC\x0b\x01\xd4\x7f\xb3|'}, service_data={'0000fd50-0000-1000-8000-00805f9b34fb': b'A\x00\x00\x08vyfoip9h'}, service_uuids=['0000fd50-0000-1000-8000-00805f9b34fb'], tx_power=-127, rssi=-80) match: {'xiaomi_ble'}
2023-07-10 20:01:40.637 INFO (SyncWorker_2) [homeassistant.loader] Loaded xiaomi_ble from homeassistant.components.xiaomi_ble
2023-07-10 20:01:40.680 DEBUG (MainThread) [xiaomi_ble.parser] Parsing Xiaomi BLE advertisement data: <home_assistant_bluetooth.models.BluetoothServiceInfoBleak object at 0x7f20715534c0>
Javitel commented 1 year ago

I do not have that integration installed and I can not registered it neither

dbuezas commented 1 year ago

I also get "no unconfigured devices found" but see nothing related in the logs.

Deoptim commented 1 year ago

Same issue: "No unconfigured devices found."

Могу подробнее про устройство рассказать: Микроконтроллер: PHY6222QC

{
  "result": {
    "active_time": 1690624537,
    "category": "wsdcg",
    "create_time": 1690624537,
    "custom_name": "",
    "icon": "smart/icon/ay1525749833414yotNt/bfd21e12a1179860998fb0bdec6a048d.png",
    "id": "bf542cn1wqrwszlc",
    "ip": "",
    "is_online": false,
    "lat": "50.0491",
    "local_key": "pId<nHR220vhJBG[",
    "lon": "36.2108",
    "model": "TH05",
    "name": "Датчик температуры и влажности",
    "product_id": "vyfoip9h",
    "product_name": "TH05蓝牙单点6222--AHT20--大货不带校准",
    "sub": false,
    "time_zone": "+03:00",
    "update_time": 1690624540,
    "uuid": "4cae0447a28f647f"
  },
  "success": true,
  "t": 1691093430305,
  "tid": "cb6fde92323911ee8d550e23a7a01039"
}

В "sudo bluetoothctl": [bluetooth]# devices Device DC:23:4F:73:0A:ED demo (название demo что уже само по себе странно) [bluetooth]# info DC:23:4F:73:0A:ED

Device DC:23:4F:73:0A:ED (public)
        Name: demo
        Alias: demo
        Paired: no
        Trusted: no
        Blocked: no
        Connected: no
        LegacyPairing: no
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: Unknown                   (0000fd50-0000-1000-8000-00805f9b34fb)
        ManufacturerData Key: 0x07d0
        ManufacturerData Value:
  00 00 01 04 c6 e8 3a 00 ab 60 72 91 f7 b8 a3 1c  ......:..`r.....
  41 ac 30 ea                                      A.0.
        ServiceData Key: 0000fd50-0000-1000-8000-00805f9b34fb
        ServiceData Value:
  49 00 00 08 6f e5 3c ca a9 7e ab 6b              I...o.<..~.k
        RSSI: -83

При сбросе устройства(зажать надолго кнопку) в логе bluetoothctl появляются такие сведения:

...
[CHG] Device DC:23:4F:73:0A:ED ManufacturerData Key: 0x07d0
[CHG] Device DC:23:4F:73:0A:ED ManufacturerData Value:
  00 00 01 04 03 ac 0e 79 ad 84 43 7a 80 e0 09 bf  .......y..Cz....
  05 1e 52 ec                                      ..R.
[CHG] Device DC:23:4F:73:0A:ED ServiceData Key: 0000fd50-0000-1000-8000-00805f9b34fb
[CHG] Device DC:23:4F:73:0A:ED ServiceData Value:
  41 00 00 08 76 79 66 6f 69 70 39 68              A...vyfoip9h
...

При подключении:

Attempting to pair with DC:23:4F:73:0A:ED
[CHG] Device DC:23:4F:73:0A:ED Connected: yes
[CHG] Device DC:23:4F:73:0A:ED Name: Demo
[CHG] Device DC:23:4F:73:0A:ED Alias: Demo
[NEW] Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_DC_23_4F_73_0A_ED/service0008
        00001801-0000-1000-8000-00805f9b34fb
        Generic Attribute Profile
[NEW] Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_DC_23_4F_73_0A_ED/service0008/char0009
        00002a05-0000-1000-8000-00805f9b34fb
        Service Changed
[NEW] Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_DC_23_4F_73_0A_ED/service0008/char0009/desc000b
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration
[NEW] Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_DC_23_4F_73_0A_ED/service000c
        0000fd50-0000-1000-8000-00805f9b34fb
        Unknown
[NEW] Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_DC_23_4F_73_0A_ED/service000c/char000d
        00000001-0000-1001-8001-00805f9b07d0
        Vendor specific
[NEW] Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_DC_23_4F_73_0A_ED/service000c/char000f
        00000002-0000-1001-8001-00805f9b07d0
        Vendor specific
[NEW] Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_DC_23_4F_73_0A_ED/service000c/char000f/desc0011
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration

Надеюсь это поможет.

carlofratamo commented 1 year ago

Hi guys.. any news? I'm blocjed at the same point of "No unconfigured devices found."

I've unliked the device from smartlife and put it near the bluetooth adapters, but nothing changed.

MiHPL commented 1 year ago

I have homeassistant in docker, and after adding -v /run/dbus:/run/dbus (I've mapped that in portainer volumes) the message "No unconfigured devices found." is gone and tuya ble is visible in integrations. But still no luck in adding TH05 :/

Deoptim commented 1 year ago

Если в tuya_ble\const.py изменить переменную

#SERVICE_UUID = "0000a201-0000-1000-8000-00805f9b34fb"
SERVICE_UUID = "0000fd50-0000-1000-8000-00805f9b34fb"

То датчик обнаруживается, но доступно только Signal Strength

GCV-Sleeper-Service commented 1 year ago

Seems someone already did some research

https://github.com/pvvx/ATC_MiThermometer/issues/268

The conclusion from this gentleman is that it is not worth the effort because when paired, it will consume so much energy that the battery will run out in 10 days.

edudele commented 1 year ago

Good afternoon, So we give up the BLE integration with ESPHOME and bluethoot proxy?

Can't do anything with this device?

GCV-Sleeper-Service commented 1 year ago

Good afternoon, So we give up the BLE integration with ESPHOME and bluethoot proxy?

Can't do anything with this device?

Apparently, nothing can be done with this device at this moment in terms of connectivity/integration and moreover, it does not worth to do anything if power consumption claims and battery longevity claims are proven true.

edudele commented 1 year ago

The CR2032 batteries can be used as rechargeable, obtain information on humidity and temperature of each of the rooms in my house for €2, it is not money in batteries even though they have to be changed every 5-6 months.

It's a real shame, I thought it could be similar to the Xiaomi Mija..¬¬

gitothy commented 1 year ago

Thanks all above for the inputs. Looks like we've all been f'd in the a on this one. My personal lesson is to make sure to get the Xiaomi model next time and not this Tuya BLE-Mesh rubbish.

edudele commented 1 year ago

Gracias a todos los de arriba por los aportes. Parece que a todos nos han jodido en este caso. Mi lección personal es asegurarme de obtener el modelo Xiaomi la próxima vez y no esta basura Tuya BLE-Mesh.

For what it's worth, I'm the same. I have already ordered 10 of XIAOMI Mijia LYWSD03MMC and it cost me €3.91 each. They are coming

gitothy commented 1 year ago

Gracias a todos los de arriba por los aportes. Parece que a todos nos han jodido en este caso. Mi lección personal es asegurarme de obtener el modelo Xiaomi la próxima vez y no esta basura Tuya BLE-Mesh.

For what it's worth, I'm the same. I have already ordered 10 of XIAOMI Mijia LYWSD03MMC and it cost me €3.91 each. They are coming

Really impressed that my "f'd in the a" got translated in to Spanish there as "nos han jodido" ('we've been screwed') 🙂

marcoahp commented 1 year ago

Screenshot_20230707_170313_Home Assistant Now, tuya ble found it, but I have this error.

In tuya cloud (smartlife app) the sensor exist.

I have three TH05, and I have the same problem. HA discover it, I have it configured in Tuya Cloud, but I get this error

maksp86 commented 1 year ago

I have similar device, with PHY6222QC SOC img To make it visible in setup I changed "CHARACTERISTIC_NOTIFY " and "CHARACTERISTIC_WRITE" to

CHARACTERISTIC_NOTIFY = "00000002-0000-1001-8001-00805f9b07d0"
CHARACTERISTIC_WRITE = "00000001-0000-1001-8001-00805f9b07d0"  

and added some datapoints to code, but in HA logs I get something like this

DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DE:AD:BE:FF:FF:FF: Initializing
DEBUG (MainThread) [custom_components.tuya_ble.cloud] Retrieved: uuid: xxxxxxxxxxxxxxxx, local_key: xxxxxxxxxxxxxxxx, device_id: xxxxxxxxxxxxxxxx, category: wsdcg, product_id: iv7hudlj, device_name: Bluetooth Temperature Humidity Sensor, product_model: UA660-WL-B0, product_name: Bluetooth Temperature Humidity Sensor
DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Updating
DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Connecting; RSSI: -78
DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Connected; RSSI: -80
DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Sending device info request
DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Sending packet: #1 FUN_SENDER_DEVICE_INFO
DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Sending packet: 002120044c48531054a678fbb7fb25b15e200a5c
DEBUG (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Sending packet: 013c389b29c787570e31f1c99915200565
WARNING (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: Device unexpectedly disconnected; RSSI: -80
ERROR (MainThread) [custom_components.tuya_ble.tuya_ble.tuya_ble] DC:23:4F:B6:3B:9D: timeout receiving response, RSSI: -76

Device info:

{
      "active_time": 1699781117,
      "biz_type": 18,
      "category": "wsdcg",
      "create_time": 1699770205,
      "icon": "smart/icon/ay1497491823009SFeNH/a5180b7191119f5edbf621a7ba21b084.png",
      "id": "***",
      "ip": "***",
      "lat": "***",
      "local_key": "***",
      "lon": "***",
      "model": "UA660-WL-B0",
      "name": "Bluetooth Temperature Humidity Sensor",
      "online": false,
      "owner_id": "***",
      "product_id": "iv7hudlj",
      "product_name": "Bluetooth Temperature Humidity Sensor",
      "status": [
        {
          "code": "va_temperature",
          "value": 256
        },
        {
          "code": "va_humidity",
          "value": 33
        },
        {
          "code": "battery_percentage",
          "value": 100
        },
        {
          "code": "temp_unit_convert",
          "value": "c"
        },
        {
          "code": "maxtemp_set",
          "value": 270
        },
        {
          "code": "minitemp_set",
          "value": 190
        },
        {
          "code": "maxhum_set",
          "value": 85
        },
        {
          "code": "minihum_set",
          "value": 20
        },
        {
          "code": "temp_alarm",
          "value": "cancel"
        },
        {
          "code": "hum_alarm",
          "value": "cancel"
        }
      ],
    },
mjaspers2mtu commented 10 months ago

Also have this device, after setting up tuya smart, tuya iot, and tuya ble for the past two hours, it seems the only device I have and wanted to add (the TH05) is not possible xD

guilleortas commented 10 months ago

Если в tuya_ble\const.py изменить переменную

#SERVICE_UUID = "0000a201-0000-1000-8000-00805f9b34fb"
SERVICE_UUID = "0000fd50-0000-1000-8000-00805f9b34fb"

То датчик обнаруживается, но доступно только Signal Strength

yep, I get the same behavior

AlgebraicMisery commented 1 month ago

Does anyone know how to swap out the battery? I am having trouble opening the back plastic