From 123b3d94a263aa68e62e92d9786ca608a74a7fa4 Mon Sep 17 00:00:00 2001 From: DigiH Date: Wed, 13 Dec 2023 13:25:16 +0100 Subject: [PATCH] CGP1W battery added --- docs/devices/CGP1W.md | 6 +++--- src/devices/CGP1W_json.h | 14 +++++++++++--- tests/BLE/test_ble.cpp | 8 ++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/docs/devices/CGP1W.md b/docs/devices/CGP1W.md index 28124c2c..87b474a9 100644 --- a/docs/devices/CGP1W.md +++ b/docs/devices/CGP1W.md @@ -1,13 +1,13 @@ -# ClearGrass Weather Station CGP1W +# ClearGrass/Qingping Weather Station CGP1W |Model Id|[CGP1W](https://github.com/theengs/decoder/blob/development/src/devices/CGP1W_json.h)| |-|-| -|Brand|ClearGrass| +|Brand|ClearGrass/Qingping| |Model|Weather Station| |Short Description|Rechargeable temperature, humidity and atmospheric pressure sensor| |Communication|BLE broadcast| |Frequency|2.4Ghz| |Power Source|Internal battery/USB| -|Exchanged Data|temperature, humidity, atmospheric pressure| +|Exchanged Data|temperature, humidity, atmospheric pressure, battery| |Encrypted|No| |Image|![CGP1W](./../img/CGP1W.png)| diff --git a/src/devices/CGP1W_json.h b/src/devices/CGP1W_json.h index 228a6387..6650d91b 100644 --- a/src/devices/CGP1W_json.h +++ b/src/devices/CGP1W_json.h @@ -1,7 +1,7 @@ -const char* _CGP1W_json = "{\"brand\":\"ClearGrass\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"tag\":\"02\",\"condition\":[\"servicedata\",\"=\",42,\"index\",2,\"09\",\"&\",\"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]},\"pres\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,4,true,false],\"post_proc\":[\"/\",10]},\"mac\":{\"decoder\":[\"revmac_from_hex_data\",\"servicedata\",4]}}}"; +const char* _CGP1W_json = "{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"tag\":\"02\",\"condition\":[\"servicedata\",\"=\",42,\"index\",2,\"09\",\"&\",\"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]},\"pres\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,4,true,false],\"post_proc\":[\"/\",10]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",40,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"revmac_from_hex_data\",\"servicedata\",4]}}}"; /*R""""( { - "brand":"ClearGrass", + "brand":"ClearGrass/Qingping", "model":"Weather Station", "model_id":"CGP1W", "tag":"02", @@ -19,13 +19,17 @@ const char* _CGP1W_json = "{\"brand\":\"ClearGrass\",\"model\":\"Weather Station "decoder":["value_from_hex_data", "servicedata", 32, 4, true, false], "post_proc":["/", 10] }, + "batt":{ + "decoder":["value_from_hex_data", "servicedata", 40, 2, false, false], + "post_proc":["&", 127] + }, "mac":{ "decoder":["revmac_from_hex_data", "servicedata", 4] } } })"""";*/ -const char* _CGP1W_json_props = "{\"properties\":{\"pres\":{\"unit\":\"hPa\",\"name\":\"pressure\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"mac\":{\"unit\":\"string\",\"name\":\"MAC address\"}}}"; +const char* _CGP1W_json_props = "{\"properties\":{\"pres\":{\"unit\":\"hPa\",\"name\":\"pressure\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"},\"mac\":{\"unit\":\"string\",\"name\":\"MAC address\"}}}"; /*R""""( { "properties":{ @@ -41,6 +45,10 @@ const char* _CGP1W_json_props = "{\"properties\":{\"pres\":{\"unit\":\"hPa\",\"n "unit":"%", "name":"humidity" }, + "batt":{ + "unit":"%", + "name":"battery" + }, "mac":{ "unit":"string", "name":"MAC address" diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index f4ea79d1..1d7bd0c5 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -268,9 +268,9 @@ const char* expected_uuid[] = { "{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Alarm Clock\",\"model_id\":\"CGC1/CGD1\",\"type\":\"THB\",\"tempc\":26.6,\"tempf\":79.88,\"hum\":63.9,\"batt\":42,\"mac\":\"58:2D:34:50:FD:AF\"}", "{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Alarm Clock\",\"model_id\":\"CGC1/CGD1\",\"type\":\"THB\",\"tempc\":26.9,\"tempf\":80.42,\"hum\":67,\"batt\":42,\"mac\":\"58:2D:34:50:FD:AF\"}", "{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Alarm Clock\",\"model_id\":\"CGC1/CGD1\",\"type\":\"THB\",\"tempc\":27,\"tempf\":80.6,\"hum\":65.7,\"batt\":85,\"mac\":\"58:2D:34:50:FD:AF\"}", - "{\"brand\":\"ClearGrass\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"type\":\"THBX\",\"tempc\":26.4,\"tempf\":79.52,\"hum\":64.7,\"pres\":1006.3,\"mac\":\"AA:BB:CC:DD:EE:FF\"}", - "{\"brand\":\"ClearGrass\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"type\":\"THBX\",\"tempc\":27.1,\"tempf\":80.78,\"hum\":64.8,\"pres\":1006.3,\"mac\":\"58:2D:34:40:01:4C\"}", - "{\"brand\":\"ClearGrass\",\"model\":\"Weather Station\",\"model_id\":\"CGP1W\",\"type\":\"THBX\",\"tempc\":25.2,\"tempf\":77.36,\"hum\":58.6,\"pres\":1008.6,\"mac\":\"58:2D:34:40:01:4C\"}", + "{\"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\"}", @@ -320,7 +320,7 @@ const char* expected_uuid[] = { "{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"type\":\"ACEL\",\"track\":true,\"tempc\":-0.45,\"tempf\":31.19,\"hum\":34.3,\"volt\":3.591,\"accx\":-4,\"accy\":-20,\"accz\":1003}", "{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"type\":\"ACEL\",\"track\":true,\"tempc\":-11.79,\"tempf\":10.778,\"hum\":43.84,\"volt\":3.672,\"accx\":15,\"accy\":-15,\"accz\":1015}", "{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"type\":\"ACEL\",\"track\":true,\"tempc\":-10.9,\"tempf\":12.38,\"hum\":74.86,\"volt\":3.675,\"accx\":-62,\"accy\":0,\"accz\":1046}", - "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"type\":\"ACTR\",\"acts\":true,\"mode\":\"onestate\",\"state\":\"on\",\"batt\":71}", + "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"type\":\"ACTR\",\"acts\":true,\"mode\":\"onestate\",\"state\":\"on\",\"batt\":71}", }; const char* expected_mac_mfg[] = {