make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.39k stars 535 forks source link

Request support for [BLE Temperature and Humidity Sensor PT216 & PT19DB-2] #434

Closed hronek closed 1 year ago

hronek commented 1 year ago

ITS Bluetooth low energy device. I am not sure if support is possible. If not, just close the issue.Thx.

DPS: { "result": { "category": "wsdcg", "functions": [ { "code": "temp_periodic_report", "dp_id": 17, "type": "Integer", "values": "{\"unit\":\"s\",\"min\":5,\"max\":60,\"scale\":0,\"step\":1}" }, { "code": "temp_sensitivity", "dp_id": 19, "type": "Integer", "values": "{\"unit\":\"℃\",\"min\":1,\"max\":10,\"scale\":1,\"step\":1}" }, { "code": "hum_sensitivity", "dp_id": 20, "type": "Integer", "values": "{\"unit\":\"%\",\"min\":3,\"max\":10,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "va_temperature", "dp_id": 1, "type": "Integer", "values": "{\"unit\":\"℃\",\"min\":-100,\"max\":500,\"scale\":1,\"step\":1}" }, { "code": "va_humidity", "dp_id": 2, "type": "Integer", "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}" }, { "code": "battery_percentage", "dp_id": 4, "type": "Integer", "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}" }, { "code": "temp_periodic_report", "dp_id": 17, "type": "Integer", "values": "{\"unit\":\"s\",\"min\":5,\"max\":60,\"scale\":0,\"step\":1}" }, { "code": "temp_sensitivity", "dp_id": 19, "type": "Integer", "values": "{\"unit\":\"℃\",\"min\":1,\"max\":10,\"scale\":1,\"step\":1}" }, { "code": "hum_sensitivity", "dp_id": 20, "type": "Integer", "values": "{\"unit\":\"%\",\"min\":3,\"max\":10,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1676720911406, "tid": "2a987685af8211ed8a3392fe1232b0cc" }

{ "result": { "active_time": 1675272731, "category": "wsdcg", "category_name": "Temperature and Humidity Sensor", "create_time": 1675258790, "gateway_id": "", "icon": "smart/icon/ay1571825171870ICRMe/88b9e6c86ebff2a293dbf3dda9e9b64c.png", "id": "bf2e65iakoo5jlms", "ip": "", "lat": "49.3146", "local_key": "MY_KEY", "lon": "14.1428", "model": "PT216 & PT19DB-2", "name": "Temperature Humidity Sensor", "online": false, "owner_id": "80342840", "product_id": "04nb6kdt", "product_name": "Temperature Humidity Sensor", "sub": false, "time_zone": "+01:00", "update_time": 1675272732, "uuid": "ade5ca41343bb2f0" }, "success": true, "t": 1676721184528, "tid": "cd632d7baf8211ed8a3392fe1232b0cc" }

make-all commented 1 year ago

Based on the details above, it seems this is not represented as a sub device going through a hub, so it may be possible to add support without waiting for subdevice support to be finished.

If you can get the device id, local key and IP address, you should be able to start the configuration process and get a log message in HA showing the local protocol details. If you can get that log message, then I think it can be added.

hronek commented 1 year ago

Sorry for the stupid question, but where do I get a "hostname" to try add this BLE device? I try it with auto. I don't see it in the manual. (it doesn't have an IP address since it's a BLE device.) Thank you

hronek commented 1 year ago

home-assistant.log: 2023-03-05 19:38:41.403 ERROR (MainThread) [custom_components.tuya_local.device] <class 'Exception'>: Unable to find device on network (specify IP address) while initialising device bf2e65iakoo5jlms 2023-03-05 19:38:41.413 WARNING (MainThread) [custom_components.tuya_local.config_flow] Connection test failed with <class 'Exception'> Unable to find device on network (specify IP address) 2023-03-05 19:38:41.566 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from supervisor (172.30.32.2). Requested URL: '/api/config'. (HomeAssistantSupervisor/2023.01.1 aiohttp/3.8.3 Python/3.10)

hronek commented 1 year ago

@make-all I tried all option's(Protocol version, pool only) but i am still unable add this device. I check device ID and Local key and they are OK. Any help, please? I still did't know what set to "IP adress or hostname" I have "Auto"

make-all commented 1 year ago

You need to set the IP address to the Ip address of your hub. You will also need to set the cid for subdevices.

hronek commented 1 year ago

@make-all But i don't have a hub. I would like to connect the sensor directly via Bluetooth to a Raspberry Pi with Homeasisstent. If I understand correctly, this is not and will not be possible?

make-all commented 1 year ago

If you use it directly via Bluetooth, it is not part of the Tuya ecosystem any more, it would just be a BLE device. So you would not need this integration.

bogorad commented 1 year ago

You need to set the IP address to the Ip address of your hub. You will also need to set the cid for subdevices.

Just for reference, and if someone also needs it: it works!

  1. use the device id of the hub
  2. use the local_key of the hub
  3. DON'T use the device id of the BLE temp sensor, instead use the "uuid" reported by Tuya's "Query Device Details in Bulk".

download

iotinkognito commented 1 year ago

IP address to the Ip address of your hub. You will also need to set the ci

By cid do you mean put the sensors UUID in the "Sub device ID" box on the integration UI?

image

mr-aleks commented 9 months ago

You need to set the IP address to the Ip address of your hub. You will also need to set the cid for subdevices.

Just for reference, and if someone also needs it: it works!

  1. use the device id of the hub
  2. use the local_key of the hub
  3. DON'T use the device id of the BLE temp sensor, instead use the "uuid" reported by Tuya's "Query Device Details in Bulk".

download

how to add if I use bluetooth directly from the Home Assistant server?

bogorad commented 9 months ago

how to add if I use bluetooth directly from the Home Assistant server?

I don't think it's possible. You need the Tuya BT-capable hub.

make-all commented 9 months ago

Someone has worked on decoding the Tuya BLE protocol in general. I don't know if it includes this specific deevice.

https://community.home-assistant.io/t/tuya-ble-integration-includes-fingerbot/562888