Skip to content

Commit

Permalink
LYWSDCGQ-battery&Temp_only (#116)
Browse files Browse the repository at this point in the history
LYWSDCGQ battery & Temp only mode broadcasting decoding
  • Loading branch information
DigiH authored May 19, 2022
1 parent 08e98c5 commit 9fdf642
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/devices/LYWSDCGQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
10 changes: 7 additions & 3 deletions src/devices/LYWSDCGQ_json.h
Original file line number Diff line number Diff line change
@@ -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]
},
Expand Down
9 changes: 9 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9fdf642

Please sign in to comment.