Skip to content

Commit

Permalink
Add Xiaomi RoPot device
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Mar 29, 2022
1 parent d3cc29e commit 6fb16a6
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docs/devices/HHCCPOT002.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Xiaomi RoPot

|Model Id|[HHCCPOT002](https://github.com/theengs/decoder/blob/development/src/devices/HHCCPOT002_json.h)|
|-|-|
|Brand|Xiaomi|
|Model|RoPot|
|Short Description|Moisture, temperature and fertility sensor|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power source|CR2032|
|Exchanged data|temperature, moisture, fertility|
|Encrypted|No|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class TheengsDecoder {
BM_V23,
MS_CDP,
GAEN,
HHCCPOT002,
BLE_ID_MAX
};

Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "devices/H5075_json.h"
#include "devices/H5102_json.h"
#include "devices/HHCCJCY01HHCC_json.h"
#include "devices/HHCCPOT002_json.h"
#include "devices/IBS_TH1_json.h"
#include "devices/IBS_TH2_json.h"
#include "devices/IBT_2X_json.h"
Expand Down Expand Up @@ -100,4 +101,5 @@ const char* _devices[][2] = {
{_BM_V23_json, _BM_V23_json_props},
{_MS_CDP_json, _MS_CDP_json_props},
{_GAEN_json, _GAEN_json_props},
{_HHCCPOT002_json, _HHCCPOT002_json_props},
};
46 changes: 46 additions & 0 deletions src/devices/HHCCPOT002_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const char* _HHCCPOT002_json = "{\"brand\":\"HHCC\",\"model\":\"Ropot\",\"model_id\":\"HHCCPOT002\",\"condition\":[\"servicedata\",\"contain\",\"5d01\"],\"properties\":{\"tempc\":{\"condition\":[\"servicedata\",25,\"4\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",30,4,true],\"post_proc\":[\"/\",10]},\"moi\":{\"condition\":[\"servicedata\",25,\"8\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",30,2,false]},\"fer\":{\"condition\":[\"servicedata\",25,\"9\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",30,4,true]}}}";
/*R""""(
{
"brand":"Xiaomi",
"model":"RoPot",
"model_id":"HHCCPOT002",
"condition":["servicedata", "contain", "5d01"],
"properties":{
"tempc":{
"condition":["servicedata", 25, "4"],
"decoder":["value_from_hex_data", "servicedata", 30, 4, true],
"post_proc":["/", 10]
},
"moi":{
"condition":["servicedata", 25, "8"],
"decoder":["value_from_hex_data", "servicedata", 30, 2, false]
},
"fer":{
"condition":["servicedata", 25, "9"],
"decoder":["value_from_hex_data", "servicedata", 30, 4, true]
}
}
})"""";*/

const char* _HHCCPOT002_json_props = "{\"properties\":{\"batt\":{\"unit\":\"%\",\"name\":\"battery\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"fer\":{\"unit\":\"µS/cm\",\"name\":\"fertility\"},\"moi\":{\"unit\":\"%\",\"name\":\"moisture\"}}}";
/*R""""(
{
"properties":{
"batt":{
"unit":"%",
"name":"battery"
},
"tempc":{
"unit":"°C",
"name":"temperature"
},
"fer":{
"unit":"µS/cm",
"name":"fertility"
},
"moi":{
"unit":"%",
"name":"moisture"
}
}
})"""";*/
10 changes: 9 additions & 1 deletion tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const char* expected_servicedata[] = {
"{\"brand\":\"Xiaomi\",\"model\":\"LYWSD03MMC\",\"model_id\":\"LYWSD03MMC_ATC\",\"tempc\":32.5,\"tempf\":90.5,\"hum\":62,\"batt\":81,\"volt\":2.939}",
"{\"brand\":\"Xiaomi\",\"model\":\"LYWSD03MMC\",\"model_id\":\"LYWSD03MMC_PVVX\",\"tempc\":21.12,\"tempf\":70.016,\"hum\":50.53,\"batt\":100,\"volt\":3.143}",
"{\"brand\":\"Qingping\",\"model\":\"Motion & Light\",\"model_id\":\"CGPR1\",\"lux\":0}",
"{\"brand\":\"Xiaomi\",\"model\":\"RoPot\",\"model_id\":\"HHCCPOT002\",\"moi\":3}",
"{\"brand\":\"Xiaomi\",\"model\":\"RoPot\",\"model_id\":\"HHCCPOT002\",\"tempc\":32,\"tempf\":89.6}",
"{\"brand\":\"Xiaomi\",\"model\":\"RoPot\",\"model_id\":\"HHCCPOT002\",\"fer\":1}",
};

const char* expected_mfg[] = {
Expand Down Expand Up @@ -75,7 +78,6 @@ const char* expected_mfg[] = {
"{\"brand\":\"BlueMaestro\",\"model\":\"TempoDisc\",\"model_id\":\"BM_V23\",\"tempc\":23.9,\"tempf\":75.02,\"dp\":10.8,\"hum\":43.5,\"volt\":2.56}",
"{\"brand\":\"GENERIC\",\"model\":\"MS-CDP\",\"model_id\":\"MS-CDP\",\"device\":\"Windows 10 Desktop\",\"salt\":\"ac6d90ec\",\"hash\":\"0132b3204cd39c7ced3e48436ba15dc6\"}",
"{\"brand\":\"Inkbird/Tenergy\",\"model\":\"iBBQ/SOLIS6\",\"model_id\":\"IBT-6XS/SOLIS-6\",\"tempc\":20,\"tempf\":68,\"tempc2\":20,\"tempf2\":68,\"tempc4\":21,\"tempf4\":69.8}",

};

const char* expected_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -147,6 +149,9 @@ const char* test_servicedata[][2] = {
{"LYWSD03MMC_ATC", "a4c138d5d49801453e510b7b62"},
{"LYWSD03MMC_PVVX", "5601cf38c1a44008bd13470c64cc0f"},
{"Qingping Motion & Light", "0812443660342d580201530f0118090400000000"},
{"RoPot", "71205d0183d20c6d8d7cc40d08100103"},
{"RoPot", "71205d0183d20c6d8d7cc40d0410024001"},
{"RoPot", "71205d0188d20c6d8d7cc40d0910020100"},
};

TheengsDecoder::BLE_ID_NUM test_svcdata_id_num[]{
Expand Down Expand Up @@ -183,6 +188,9 @@ TheengsDecoder::BLE_ID_NUM test_svcdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_ATC,
TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_PVVX,
TheengsDecoder::BLE_ID_NUM::CGPR1,
TheengsDecoder::BLE_ID_NUM::HHCCPOT002,
TheengsDecoder::BLE_ID_NUM::HHCCPOT002,
TheengsDecoder::BLE_ID_NUM::HHCCPOT002,
};

// manufacturer data test input [test name] [device name] [data]
Expand Down

0 comments on commit 6fb16a6

Please sign in to comment.