diff --git a/docs/devices/LYWSDCGQ.md b/docs/devices/LYWSDCGQ.md index b7a4cebd..7ad54d96 100644 --- a/docs/devices/LYWSDCGQ.md +++ b/docs/devices/LYWSDCGQ.md @@ -8,5 +8,5 @@ |Communication|BLE broadcast| |Frequency|2.4Ghz| |Power source|1 AAA| -|Exchanged data|temperature, humidity| +|Exchanged data|temperature, humidity, battery| |Encrypted|No| diff --git a/src/devices/LYWSDCGQ_json.h b/src/devices/LYWSDCGQ_json.h index 2190e9af..0c7218c9 100644 --- a/src/devices/LYWSDCGQ_json.h +++ b/src/devices/LYWSDCGQ_json.h @@ -1,15 +1,19 @@ #include "common_props.h" -const char* _LYWSDCGQ_json = "{\"brand\":\"Xiaomi\",\"model\":\"Mi Jia round\",\"model_id\":\"LYWSDCGQ\",\"condition\":[\"servicedata\",\"index\",2,\"20aa01\"],\"properties\":{\"tempc\":{\"condition\":[\"servicedata\",23,\"d\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",28,4,true],\"post_proc\":[\"/\",10]},\"hum\":{\"condition\":[\"servicedata\",23,\"d\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,4,true,false],\"post_proc\":[\"/\",10]},\"_hum\":{\"condition\":[\"servicedata\",23,\"6\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",28,4,true,false],\"post_proc\":[\"/\",10]}}}"; +const char* _LYWSDCGQ_json = "{\"brand\":\"Xiaomi\",\"model\":\"Mi Jia round\",\"model_id\":\"LYWSDCGQ\",\"condition\":[\"servicedata\",\"index\",2,\"20aa01\"],\"properties\":{\"batt\":{\"condition\":[\"servicedata\",23,\"a\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",28,2,false,false]},\"tempc\":{\"condition\":[\"servicedata\",23,\"d\",\"|\",\"servicedata\",23,\"4\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",28,4,true],\"post_proc\":[\"/\",10]},\"hum\":{\"condition\":[\"servicedata\",23,\"d\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,4,true,false],\"post_proc\":[\"/\",10]},\"_hum\":{\"condition\":[\"servicedata\",23,\"6\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",28,4,true,false],\"post_proc\":[\"/\",10]}}}"; /*R""""( { "brand":"Xiaomi", "model":"Mi Jia round", "model_id":"LYWSDCGQ", - "condition":[""servicedata", "index", 2, "20aa01"], + "condition":["servicedata", "index", 2, "20aa01"], "properties":{ + "batt":{ + "condition":["servicedata", 23, "a"], + "decoder":["value_from_hex_data", "servicedata", 28, 2, false, false] + }, "tempc":{ - "condition":["servicedata", 23, "d"], + "condition":["servicedata", 23, "d", "|", "servicedata", 23, "4"], "decoder":["value_from_hex_data", "servicedata", 28, 4, true], "post_proc":["/", 10] }, diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index be634971..88e21efb 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -15,6 +15,9 @@ const char* expected_servicedata[] = { "{\"brand\":\"Xiaomi\",\"model\":\"Cleargrass clock\",\"model_id\":\"LYWSD02\",\"tempc\":26.5,\"tempf\":79.7}", "{\"brand\":\"Xiaomi\",\"model\":\"Mi Jia round\",\"model_id\":\"LYWSDCGQ\",\"tempc\":26,\"tempf\":78.8,\"hum\":61.4}", "{\"brand\":\"Xiaomi\",\"model\":\"Mi Jia round\",\"model_id\":\"LYWSDCGQ\",\"hum\":61.4}", + "{\"brand\":\"Xiaomi\",\"model\":\"Mi Jia round\",\"model_id\":\"LYWSDCGQ\",\"batt\":81}", + "{\"brand\":\"Xiaomi\",\"model\":\"Mi Jia round\",\"model_id\":\"LYWSDCGQ\",\"batt\":62}", + "{\"brand\":\"Xiaomi\",\"model\":\"Mi Jia round\",\"model_id\":\"LYWSDCGQ\",\"tempc\":27.4,\"tempf\":81.32}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_THP\",\"model_id\":\"CGP1W\",\"tempc\":26.4,\"tempf\":79.52,\"hum\":64.7,\"pres\":100.63}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_THP\",\"model_id\":\"CGP1W\",\"tempc\":27.1,\"tempf\":80.78,\"hum\":64.8,\"pres\":100.63}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_THP\",\"model_id\":\"CGP1W\",\"tempc\":25.2,\"tempf\":77.36,\"hum\":58.6,\"pres\":100.86}", @@ -128,6 +131,9 @@ const char* test_servicedata[][2] = { {"Cleargrass clock", "70205b04756ab883c8593f090410020901"}, {"Mi jia round sensor", "5020aa0137dfaa33342d580d100404016602"}, {"Mi jia round sensor", "5020aa018ddfaa33342d580610026602"}, + {"Mi jia round sensor", "5020aa0155aabbccddeeff0a100151"}, + {"Mi jia round sensor", "5020aa01123c0338342d580a10013e"}, + {"Mi jia round sensor", "5020aa018ddfaa33342d580410021201"}, {"Cleargrass THP sensor", "08094c0140342d5801040801870207024f2702015c"}, {"Cleargrass THP sensor", "08094c0140342d5801040f01880207024f2702015c"}, {"Cleargrass THP sensor", "08094c0140342d580104fc004a0207026627020120"}, @@ -168,6 +174,9 @@ TheengsDecoder::BLE_ID_NUM test_svcdata_id_num[]{ TheengsDecoder::BLE_ID_NUM::LYWSD02, TheengsDecoder::BLE_ID_NUM::LYWSDCGQ, TheengsDecoder::BLE_ID_NUM::LYWSDCGQ, + TheengsDecoder::BLE_ID_NUM::LYWSDCGQ, + TheengsDecoder::BLE_ID_NUM::LYWSDCGQ, + TheengsDecoder::BLE_ID_NUM::LYWSDCGQ, TheengsDecoder::BLE_ID_NUM::CGP1W, TheengsDecoder::BLE_ID_NUM::CGP1W, TheengsDecoder::BLE_ID_NUM::CGP1W,