Skip to content

Commit 1475252

Browse files
authored
Tuya THB1 BTH01 TH05F PVVX decoder consolidation (#683)
1 parent 985660f commit 1475252

File tree

7 files changed

+27
-76
lines changed

7 files changed

+27
-76
lines changed

docs/devices/BTH01.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Tuya BTH01
22

33

4-
|Model Id|[BTH01](https://github.com/theengs/decoder/blob/development/src/devices/BTH01_json.h)|
4+
|Model Id|[BTH01](https://github.com/theengs/decoder/blob/development/src/devices/THB1_json.h)|
55
|-|-|
66
|Brand|Tuya|
77
|Model|BTH01 Thermo-Hygrometer|

docs/devices/TH05F.md

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

src/decoder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ class TheengsDecoder {
150150
T201,
151151
T301,
152152
THB1,
153-
BTH01,
154153
NUT,
155154
NUTALE,
156155
ITAG,

src/devices.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
#include "devices/T201_json.h"
9797
#include "devices/T301_json.h"
9898
#include "devices/THB1_json.h"
99-
#include "devices/BTH01_json.h"
10099
#include "devices/tracker_json.h"
101100
#include "devices/iNodeEM_json.h"
102101
#include "devices/ARANET4_json.h"
@@ -247,7 +246,6 @@ const char* _devices[][2] = {
247246
{_T201_json, _T201_json_props},
248247
{_T301_json, _T301_json_props},
249248
{_THB1_json, _THB1_json_props},
250-
{_BTH01_json, _BTH01_json_props},
251249
{_tracker_json_nut, _tracker_json_props},
252250
{_tracker_json_nutale, _tracker_json_props},
253251
{_tracker_json_itag, _tracker_json_props},

src/devices/BTH01_json.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/devices/THB1_json.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const char* _THB1_json = "{\"brand\":\"Tuya\",\"model\":\"THB1 Thermo-Hygrometer\",\"model_id\":\"THB1\",\"tag\":\"0102\",\"condition\":[\"servicedata\",\"=\",28,\"index\",0,\"40\",\"&\",\"uuid\",\"index\",0,\"fcd2\",\"&\",\"name\",\"index\",0,\"THB1\"],\"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]}}}";
1+
const char* _THB1_json = "{\"brand\":\"Tuya\",\"model\":\"Thermo-Hygrometer\",\"model_id\":\"THB1/BTH01/TH05F\",\"tag\":\"0102\",\"condition\":[\"name\",\"index\",0,\"THB1\",\"|\",\"name\",\"index\",0,\"BTH01\",\"|\",\"name\",\"index\",0,\"TH05F\",\"&\",\"servicedata\",\"=\",28,\"index\",0,\"40\",\"&\",\"uuid\",\"index\",0,\"fcd2\"],\"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]}}}";
22
/* R""""(
33
{
44
"brand":"Tuya",
5-
"model":"THB1 Thermo-Hygrometer",
6-
"model_id":"THB1",
5+
"model":"Thermo-Hygrometer",
6+
"model_id":"THB1/BTH01/TH05F",
77
"tag":"0102",
8-
"condition":["servicedata", "=", 28, "index", 0, "40", "&", "uuid", "index", 0, "fcd2", "&", "name", "index", 0, "THB1"],
8+
"condition":["name", "index", 0, "THB1", "|", "name", "index", 0, "BTH01", "|", "name", "index", 0, "TH05F", "&", "servicedata", "=", 28, "index", 0, "40", "&", "uuid", "index", 0, "fcd2" ],
99
"properties":{
1010
"packet":{
1111
"condition":["servicedata", 2, "00"],

tests/BLE/test_ble.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,18 @@ const char* expected_uuid_name_svcdata[] = {
385385
"{\"brand\":\"Sensor Easy\",\"model\":\"SE MAG\",\"model_id\":\"SE_MAG\",\"type\":\"CTMO\",\"open\":true,\"cont\":true}",
386386
"{\"brand\":\"Sensor Easy\",\"model\":\"SE MAG\",\"model_id\":\"SE_MAG\",\"type\":\"CTMO\",\"open\":false,\"cont\":true}",
387387
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"batt\":65}",
388-
"{\"brand\":\"Tuya\",\"model\":\"THB1 Thermo-Hygrometer\",\"model_id\":\"THB1\",\"type\":\"THB\",\"acts\":true,\"packet\":239,\"tempc\":17.94,\"tempf\":64.292,\"hum\":60.72,\"batt\":74,\"volt\":2.748}",
388+
"{\"brand\":\"Tuya\",\"model\":\"Thermo-Hygrometer\",\"model_id\":\"THB1/BTH01/TH05F\",\"type\":\"THB\",\"acts\":true,\"packet\":239,\"tempc\":17.94,\"tempf\":64.292,\"hum\":60.72,\"batt\":74,\"volt\":2.748}",
389389
"{\"brand\":\"Xiaomi\",\"model\":\"TH Sensor\",\"model_id\":\"LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME\",\"type\":\"THB\",\"acts\":true,\"packet_1\":132,\"tempc\":20.79,\"tempf\":69.422,\"hum\":71.88,\"batt\":100}",
390390
"{\"brand\":\"Xiaomi\",\"model\":\"TH Sensor\",\"model_id\":\"LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME\",\"type\":\"THB\",\"acts\":true,\"packet_2\":129,\"volt\":3.034,\"power\":1,\"open\":1}",
391391
"{\"brand\":\"Xiaomi\",\"model\":\"TH Sensor\",\"model_id\":\"LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME_ENCR\",\"type\":\"THB\",\"acts\":true,\"encr\":2,\"cipher\":\"be07860de133b342\",\"ctr\":\"23020000\",\"mic\":\"50dea27d\"}",
392392
"{\"brand\":\"Xiaomi\",\"model\":\"TH Sensor\",\"model_id\":\"LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME_ENCR\",\"type\":\"THB\",\"acts\":true,\"encr\":2,\"cipher\":\"613c80e969f052\",\"ctr\":\"a9000000\",\"mic\":\"77b39384\"}",
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}",
396+
"{\"brand\":\"Tuya\",\"model\":\"Thermo-Hygrometer\",\"model_id\":\"THB1/BTH01/TH05F\",\"type\":\"THB\",\"acts\":true,\"packet\":21,\"tempc\":25.42,\"tempf\":77.756,\"hum\":38.42,\"batt\":100,\"volt\":3.112}",
397+
"{\"brand\":\"Tuya\",\"model\":\"Thermo-Hygrometer\",\"model_id\":\"THB1/BTH01/TH05F\",\"type\":\"THB\",\"acts\":true,\"packet\":28,\"tempc\":25.34,\"tempf\":77.612,\"hum\":38.26,\"batt\":100,\"volt\":3.12}",
398+
"{\"brand\":\"Tuya\",\"model\":\"Thermo-Hygrometer\",\"model_id\":\"THB1/BTH01/TH05F\",\"type\":\"THB\",\"acts\":true,\"packet\":97,\"tempc\":28.01,\"tempf\":82.418,\"hum\":85.48,\"batt\":100,\"volt\":3.13}",
399+
"{\"brand\":\"Tuya\",\"model\":\"Thermo-Hygrometer\",\"model_id\":\"THB1/BTH01/TH05F\",\"type\":\"THB\",\"acts\":true,\"packet\":163,\"tempc\":26.92,\"tempf\":80.456,\"hum\":67.06,\"batt\":81,\"volt\":2.814}",
399400
};
400401

401402
const char* expected_uuid[] = {
@@ -1262,6 +1263,7 @@ const char* test_uuid_name_svcdata[][4] = {
12621263
{"BTH01 PVVX", "0xfcd2", "BTH01-DDEEFF", "400015016402ee0903020f0c280c"},
12631264
{"BTH01 PVVX", "0xfcd2", "BTH01-DDEEFF", "40001c016402e60903f20e0c300c"},
12641265
{"BTH01 PVVX", "0xfcd2", "BTH01-DDEEFF", "400061016402f10a0364210c3a0c"},
1266+
{"TH05F PVVX", "0xfcd2", "TH05F-C451CC", "4000a3015102840a03321a0cfe0a"},
12651267
};
12661268

12671269
TheengsDecoder::BLE_ID_NUM test_uuid_name_svcdata_id_num[]{
@@ -1365,9 +1367,10 @@ TheengsDecoder::BLE_ID_NUM test_uuid_name_svcdata_id_num[]{
13651367
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
13661368
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
13671369
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
1368-
TheengsDecoder::BLE_ID_NUM::BTH01,
1369-
TheengsDecoder::BLE_ID_NUM::BTH01,
1370-
TheengsDecoder::BLE_ID_NUM::BTH01,
1370+
TheengsDecoder::BLE_ID_NUM::THB1,
1371+
TheengsDecoder::BLE_ID_NUM::THB1,
1372+
TheengsDecoder::BLE_ID_NUM::THB1,
1373+
TheengsDecoder::BLE_ID_NUM::THB1,
13711374
};
13721375

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

0 commit comments

Comments
 (0)