Skip to content

Commit 985660f

Browse files
authored
BTH01 OVVX BTHome decoder (#682)
1 parent c4daa97 commit 985660f

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

docs/devices/BTH01.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Tuya BTH01
2+
3+
4+
|Model Id|[BTH01](https://github.com/theengs/decoder/blob/development/src/devices/BTH01_json.h)|
5+
|-|-|
6+
|Brand|Tuya|
7+
|Model|BTH01 Thermo-Hygrometer|
8+
|Short Description|Temperature and humidity sensor with PVVX firmware|
9+
|Communication|BLE broadcast|
10+
|Frequency|2.4Ghz|
11+
|Power Source|2 AAA|
12+
|Exchanged Data|temperature, humidity, battery, voltage|
13+
|Encrypted|No|

src/decoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class TheengsDecoder {
150150
T201,
151151
T301,
152152
THB1,
153+
BTH01,
153154
NUT,
154155
NUTALE,
155156
ITAG,

src/devices.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
#include "devices/T201_json.h"
9797
#include "devices/T301_json.h"
9898
#include "devices/THB1_json.h"
99+
#include "devices/BTH01_json.h"
99100
#include "devices/tracker_json.h"
100101
#include "devices/iNodeEM_json.h"
101102
#include "devices/ARANET4_json.h"
@@ -246,6 +247,7 @@ const char* _devices[][2] = {
246247
{_T201_json, _T201_json_props},
247248
{_T301_json, _T301_json_props},
248249
{_THB1_json, _THB1_json_props},
250+
{_BTH01_json, _BTH01_json_props},
249251
{_tracker_json_nut, _tracker_json_props},
250252
{_tracker_json_nutale, _tracker_json_props},
251253
{_tracker_json_itag, _tracker_json_props},

src/devices/BTH01_json.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const char* _BTH01_json = "{\"brand\":\"Tuya\",\"model\":\"BTH01 Thermo-Hygrometer\",\"model_id\":\"BTH01\",\"tag\":\"0102\",\"condition\":[\"servicedata\",\"=\",28,\"index\",0,\"40\",\"&\",\"uuid\",\"index\",0,\"fcd2\",\"&\",\"name\",\"index\",0,\"BTH01\"],\"properties\":{\"packet\":{\"condition\":[\"servicedata\",2,\"00\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"tempc\":{\"condition\":[\"servicedata\",10,\"02\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,4,true,true],\"post_proc\":[\"/\",100]},\"hum\":{\"condition\":[\"servicedata\",16,\"03\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",18,4,true,false],\"post_proc\":[\"/\",100]},\"batt\":{\"condition\":[\"servicedata\",6,\"01\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,2,false,false]},\"volt\":{\"condition\":[\"servicedata\",22,\"0c\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,4,true,false],\"post_proc\":[\"/\",1000]}}}";
2+
/* R""""(
3+
{
4+
"brand":"Tuya",
5+
"model":"BTH01 Thermo-Hygrometer",
6+
"model_id":"BTH01",
7+
"tag":"0102",
8+
"condition":["servicedata", "=", 28, "index", 0, "40", "&", "uuid", "index", 0, "fcd2", "&", "name", "index", 0, "BTH01"],
9+
"properties":{
10+
"packet":{
11+
"condition":["servicedata", 2, "00"],
12+
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false]
13+
},
14+
"tempc":{
15+
"condition":["servicedata", 10, "02"],
16+
"decoder":["value_from_hex_data", "servicedata", 12, 4, true, true],
17+
"post_proc":["/", 100]
18+
},
19+
"hum":{
20+
"condition":["servicedata", 16, "03"],
21+
"decoder":["value_from_hex_data", "servicedata", 18, 4, true, false],
22+
"post_proc":["/", 100]
23+
},
24+
"batt":{
25+
"condition":["servicedata", 6, "01"],
26+
"decoder":["value_from_hex_data", "servicedata", 8, 2, false, false]
27+
},
28+
"volt":{
29+
"condition":["servicedata", 22, "0c"],
30+
"decoder":["value_from_hex_data", "servicedata", 24, 4, true, false],
31+
"post_proc":["/", 1000]
32+
}
33+
}
34+
})"""";*/
35+
36+
const char* _BTH01_json_props = "{\"properties\":{\"packet\":{\"unit\":\"int\",\"name\":\"packet id\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"},\"volt\":{\"unit\":\"V\",\"name\":\"voltage\"}}}";
37+
/*R""""(
38+
{
39+
"properties":{
40+
"packet":{
41+
"unit":"int",
42+
"name":"packet id"
43+
},
44+
"tempc":{
45+
"unit":"°C",
46+
"name":"temperature"
47+
},
48+
"hum":{
49+
"unit":"%",
50+
"name":"humidity"
51+
},
52+
"batt":{
53+
"unit":"%",
54+
"name":"battery"
55+
},
56+
"volt": {
57+
"unit": "V",
58+
"name": "voltage"
59+
}
60+
}
61+
})"""";*/

tests/BLE/test_ble.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ const char* expected_uuid_name_svcdata[] = {
393393
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv2.0\",\"type\":\"PLANT\",\"acts\":true,\"tempc\":26.55,\"tempf\":79.79,\"hum\":51,\"moi\":0,\"lux\":0,\"batt\":100,\"volt\":3.016}",
394394
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv2.0\",\"type\":\"PLANT\",\"acts\":true,\"tempc\":27.68,\"tempf\":81.824,\"hum\":73,\"moi\":66,\"lux\":0,\"batt\":100,\"volt\":3.016}",
395395
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv2.0\",\"type\":\"PLANT\",\"acts\":true,\"tempc\":30.36,\"tempf\":86.648,\"hum\":85,\"moi\":74,\"lux\":8392,\"batt\":100,\"volt\":3.005}",
396+
"{\"brand\":\"Tuya\",\"model\":\"BTH01 Thermo-Hygrometer\",\"model_id\":\"BTH01\",\"type\":\"THB\",\"acts\":true,\"packet\":21,\"tempc\":25.42,\"tempf\":77.756,\"hum\":38.42,\"batt\":100,\"volt\":3.112}",
397+
"{\"brand\":\"Tuya\",\"model\":\"BTH01 Thermo-Hygrometer\",\"model_id\":\"BTH01\",\"type\":\"THB\",\"acts\":true,\"packet\":28,\"tempc\":25.34,\"tempf\":77.612,\"hum\":38.26,\"batt\":100,\"volt\":3.12}",
398+
"{\"brand\":\"Tuya\",\"model\":\"BTH01 Thermo-Hygrometer\",\"model_id\":\"BTH01\",\"type\":\"THB\",\"acts\":true,\"packet\":97,\"tempc\":28.01,\"tempf\":82.418,\"hum\":85.48,\"batt\":100,\"volt\":3.13}",
396399
};
397400

398401
const char* expected_uuid[] = {
@@ -1256,6 +1259,9 @@ const char* test_uuid_name_svcdata[][4] = {
12561259
{"bParasiteV2", "0xfcd2", "prst", "400164025f0a050000000cc80b2e332f00"},
12571260
{"bParasiteV2", "0xfcd2", "prst", "40016402d00a050000000cc80b2e492f42"},
12581261
{"bParasiteV2", "0xfcd2", "prst", "40016402dc0b0520ce0c0cbd0b2e552f4a"},
1262+
{"BTH01 PVVX", "0xfcd2", "BTH01-DDEEFF", "400015016402ee0903020f0c280c"},
1263+
{"BTH01 PVVX", "0xfcd2", "BTH01-DDEEFF", "40001c016402e60903f20e0c300c"},
1264+
{"BTH01 PVVX", "0xfcd2", "BTH01-DDEEFF", "400061016402f10a0364210c3a0c"},
12591265
};
12601266

12611267
TheengsDecoder::BLE_ID_NUM test_uuid_name_svcdata_id_num[]{
@@ -1359,6 +1365,9 @@ TheengsDecoder::BLE_ID_NUM test_uuid_name_svcdata_id_num[]{
13591365
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
13601366
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
13611367
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
1368+
TheengsDecoder::BLE_ID_NUM::BTH01,
1369+
TheengsDecoder::BLE_ID_NUM::BTH01,
1370+
TheengsDecoder::BLE_ID_NUM::BTH01,
13621371
};
13631372

13641373
// uuid test input [test name] [uuid] [data source] [data]

0 commit comments

Comments
 (0)