Skip to content

Commit

Permalink
Battery state for Qingping TH lite (#594)
Browse files Browse the repository at this point in the history
* Added battery state to Qingping TH Lite CGDK2

* Renamed battery->batt.

* Added battery state to Qingping TH Lite CGDK2

* Updated tests for Qingping TH lite.
  • Loading branch information
XHunter74 authored Dec 28, 2024
1 parent 009593a commit 7cb9a9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/devices/CGDK2_json.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common_props.h"

const char* _CGDK2_json_STOCK = "{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"tag\":\"01\",\"condition\":[\"servicedata\",\"=\",34,\"index\",2,\"10\",\"&\",\"uuid\",\"index\",0,\"fdcd\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true],\"post_proc\":[\"/\",10]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,4,true,false],\"post_proc\":[\"/\",10]},\"mac\":{\"decoder\":[\"revmac_from_hex_data\",\"servicedata\",4]}}}";
const char* _CGDK2_json_STOCK = "{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"tag\":\"01\",\"condition\":[\"servicedata\",\"=\",34,\"index\",2,\"10\",\"&\",\"uuid\",\"index\",0,\"fdcd\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true],\"post_proc\":[\"/\",10]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,4,true,false],\"post_proc\":[\"/\",10]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,2,false]},\"mac\":{\"decoder\":[\"revmac_from_hex_data\",\"servicedata\",4]}}}";
/*R""""(
{
"brand":"Qingping",
Expand All @@ -17,6 +17,9 @@ const char* _CGDK2_json_STOCK = "{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\
"decoder":["value_from_hex_data", "servicedata", 24, 4, true, false],
"post_proc":["/", 10]
},
"batt":{
"decoder":["value_from_hex_data", "servicedata", 32, 2, false]
},
"mac":{
"decoder":["revmac_from_hex_data", "servicedata", 4]
}
Expand Down
12 changes: 6 additions & 6 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ const char* expected_uuid[] = {
"{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"type\":\"THBX\",\"tempc\":26.4,\"tempf\":79.52,\"hum\":64.7,\"pres\":1006.3,\"batt\":92,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"type\":\"THBX\",\"tempc\":27.1,\"tempf\":80.78,\"hum\":64.8,\"pres\":1006.3,\"batt\":92,\"mac\":\"58:2D:34:40:01:4C\"}",
"{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"type\":\"THBX\",\"tempc\":25.2,\"tempf\":77.36,\"hum\":58.6,\"pres\":1008.6,\"batt\":32,\"mac\":\"58:2D:34:40:01:4C\"}",
"{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"type\":\"THB\",\"tempc\":23.2,\"tempf\":73.76,\"hum\":91.1,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"type\":\"THB\",\"tempc\":23.3,\"tempf\":73.94,\"hum\":54.1,\"mac\":\"58:2D:34:11:91:79\"}",
"{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"type\":\"THB\",\"tempc\":23.3,\"tempf\":73.94,\"hum\":54.1,\"mac\":\"58:2D:34:11:91:79\"}",
"{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"type\":\"THB\",\"tempc\":23.2,\"tempf\":73.76,\"hum\":91.1,\"batt\":77,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"type\":\"THB\",\"tempc\":23.3,\"tempf\":73.94,\"hum\":54.1,\"batt\":77,\"mac\":\"58:2D:34:11:91:79\"}",
"{\"brand\":\"Qingping\",\"model\":\"TH Lite\",\"model_id\":\"CGDK2\",\"type\":\"THB\",\"tempc\":23.3,\"tempf\":73.94,\"hum\":54.1,\"batt\":77,\"mac\":\"58:2D:34:11:91:79\"}",
"{\"brand\":\"Qingping\",\"model\":\"Motion & Light\",\"model_id\":\"CGPR1\",\"type\":\"CTMO\",\"cont\":true,\"lux\":0,\"batt\":83,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Qingping\",\"model\":\"Motion & Light\",\"model_id\":\"CGPR1\",\"type\":\"CTMO\",\"cont\":true,\"lux\":517,\"batt\":100,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Qingping\",\"model\":\"Motion & Light\",\"model_id\":\"CGPR1\",\"type\":\"CTMO\",\"cont\":true,\"lux\":3,\"motion\":true,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
Expand Down Expand Up @@ -1243,9 +1243,9 @@ const char* test_uuid[][4] = {
{"ClearGrass Weather Station", "0xfdcd", "servicedata", "0809ffeeddccbbaa01040801870207024f2702015c"},
{"ClearGrass Weather Station", "0xfdcd", "servicedata", "08094c0140342d5801040f01880207024f2702015c"},
{"ClearGrass Weather Station", "0xfdcd", "servicedata", "08094c0140342d580104fc004a0207026627020120"},
{"Qingping TH lite", "0xfdcd", "servicedata", "8810ffeeddccbbaa0104e8008f0302010b"},
{"Qingping TH lite", "0xfdcd", "servicedata", "8810799111342d580104e9001d0202010b"},
{"Qingping TH lite", "0xfdcd", "servicedata", "0810799111342d580104e9001d0202010b"},
{"Qingping TH lite", "0xfdcd", "servicedata", "8810ffeeddccbbaa0104e8008f0302014d"},
{"Qingping TH lite", "0xfdcd", "servicedata", "8810799111342d580104e9001d0202014d"},
{"Qingping TH lite", "0xfdcd", "servicedata", "0810799111342d580104e9001d0202014d"},
{"Qingping Motion & Light", "0xfdcd", "servicedata", "0812ffeeddccbbaa0201530f0118090400000000"},
{"Qingping Motion & Light", "0xfdcd", "servicedata", "8812ffeeddccbbaa0201640f01c4090405020000"},
{"Qingping Motion & Light", "0xfdcd", "servicedata", "4812ffeeddccbbaa0804010300000f0150"},
Expand Down

0 comments on commit 7cb9a9c

Please sign in to comment.