From aeb58922cc6c388478afc14e9d7ac514e49c889f Mon Sep 17 00:00:00 2001 From: DigiH Date: Sat, 1 Apr 2023 22:26:10 +0200 Subject: [PATCH 1/2] HHCCJCY10 HHCCJCY10 pink Tuya version --- docs/devices/HHCCJCY10.md | 12 ++++++++ src/decoder.h | 1 + src/devices.h | 2 ++ src/devices/HHCCJCY10_json.h | 54 ++++++++++++++++++++++++++++++++++++ tests/BLE/test_ble.cpp | 6 ++++ 5 files changed, 75 insertions(+) create mode 100644 docs/devices/HHCCJCY10.md create mode 100644 src/devices/HHCCJCY10_json.h diff --git a/docs/devices/HHCCJCY10.md b/docs/devices/HHCCJCY10.md new file mode 100644 index 00000000..50017815 --- /dev/null +++ b/docs/devices/HHCCJCY10.md @@ -0,0 +1,12 @@ +# Xiaomi Mi Flora (pink version) + +|Model Id|[HHCCJCY10](https://github.com/theengs/decoder/blob/development/src/devices/HHCCJCY10_json.h)| +|-|-| +|Brand|Xiaomi| +|Model|MiFlora| +|Short Description|Temperature, moisture, light and fertility sensor| +|Communication|BLE broadcast| +|Frequency|2.4Ghz| +|Power source|CR2032| +|Exchanged data|temperature, moisture, luminance, fertility, battery| +|Encrypted|No| diff --git a/src/decoder.h b/src/decoder.h index 2d127719..f703a673 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -79,6 +79,7 @@ class TheengsDecoder { H5074, H5102, H5106, + HHCCJCY10, MUE4094RT, MOKOBEACON, MOKOBEACONXPRO, diff --git a/src/devices.h b/src/devices.h index a20c8305..f3c911f8 100644 --- a/src/devices.h +++ b/src/devices.h @@ -32,6 +32,7 @@ #include "devices/H5074_json.h" #include "devices/H5102_json.h" #include "devices/H5106_json.h" +#include "devices/HHCCJCY10_json.h" #include "devices/HHCCJCY01HHCC_json.h" #include "devices/HHCCPOT002_json.h" #include "devices/IBS_THBP01B_json.h" @@ -120,6 +121,7 @@ const char* _devices[][2] = { {_H5074_json, _H5074_json_props}, {_H5102_json, _H5102_json_props}, {_H5106_json, _H5106_json_props}, + {_HHCCJCY10_json, _HHCCJCY10_json_props}, {_MUE4094RT_json, _MUE4094RT_json_props}, {_Mokobeacon_json, _Mokobeacon_json_props}, {_MBXPRO_json, _MBXPRO_json_props}, diff --git a/src/devices/HHCCJCY10_json.h b/src/devices/HHCCJCY10_json.h new file mode 100644 index 00000000..bf303a6e --- /dev/null +++ b/src/devices/HHCCJCY10_json.h @@ -0,0 +1,54 @@ +const char* _HHCCJCY10_json = "{\"brand\":\"Xiaomi/VegTrug\",\"model\":\"MiFlora\",\"model_id\":\"HHCCJCY10\",\"tag\":\"09\",\"condition\":[\"servicedata\",\"=\",18,\"&\",\"uuid\",\"index\",0,\"fd50\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",2,4,false,true],\"post_proc\":[\"/\",10]},\"moi\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",0,2,false,false]},\"lux\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,6,false,false]},\"fer\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,4,false,false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,false]}}}"; +/*R""""( +{ + "brand":"Xiaomi/VegTrug", + "model":"MiFlora", + "model_id":"HHCCJCY10", + "tag":"09", + "condition":["servicedata", "=", 18, "&", "uuid", "index", 0, "fd50"], + "properties":{ + "tempc":{ + "decoder":["value_from_hex_data", "servicedata", 2, 4, false, true], + "post_proc":["/", 10] + }, + "moi":{ + "decoder":["value_from_hex_data", "servicedata", 0, 2, false, false] + }, + "lux":{ + "decoder":["value_from_hex_data", "servicedata", 6, 6, false, false] + }, + "fer":{ + "decoder":["value_from_hex_data", "servicedata", 14, 4, false, false] + }, + "batt":{ + "decoder":["value_from_hex_data", "servicedata", 12, 2, false, false] + } + } +})"""";*/ + +const char* _HHCCJCY10_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"moi\":{\"unit\":\"%\",\"name\":\"moisture\"},\"lux\":{\"unit\":\"lx\",\"name\":\"illuminance\"},\"fer\":{\"unit\":\"µS/cm\",\"name\":\"fertility\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"}}}"; +/*R""""( +{ + "properties":{ + "tempc":{ + "unit":"°C", + "name":"temperature" + }, + "moi":{ + "unit":"%", + "name":"moisture" + }, + "lux":{ + "unit":"lx", + "name":"illuminance" + }, + "fer":{ + "unit":"µS/cm", + "name":"fertility" + }, + "batt":{ + "unit":"%", + "name":"battery" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 8a34d711..97116145 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -248,6 +248,8 @@ const char* expected_uuid[] = { "{\"brand\":\"Tile\",\"model\":\"Smart Tracker\",\"model_id\":\"TILE\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"Tile Tracker\"}", "{\"brand\":\"Tile\",\"model\":\"Smart Tracker\",\"model_id\":\"TILE\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"Tile Tracker\"}", "{\"brand\":\"Tile\",\"model\":\"Smart Tracker\",\"model_id\":\"TILE\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"Tile Tracker\"}", + "{\"brand\":\"Xiaomi/VegTrug\",\"model\":\"MiFlora\",\"model_id\":\"HHCCJCY10\",\"type\":\"PLANT\",\"tempc\":11,\"tempf\":51.8,\"moi\":14,\"lux\":79012,\"fer\":91,\"batt\":40}", + "{\"brand\":\"Xiaomi/VegTrug\",\"model\":\"MiFlora\",\"model_id\":\"HHCCJCY10\",\"type\":\"PLANT\",\"tempc\":0,\"tempf\":32,\"moi\":98,\"lux\":71,\"fer\":0,\"batt\":100}", }; const char* expected_mac_mfg[] = { @@ -676,6 +678,8 @@ const char* test_uuid[][4] = { {"Tile uuid", "0xfeed", "servicedata", "0200c58aaccd312f479e"}, {"Tile uuid", "0xfeec", "servicedata", "0200c58aaccd312f479e"}, {"Tile uuid", "0xfd84", "servicedata", "0200c58aaccd312f479e"}, + {"Mi flora pink tuya", "0xfd50", "servicedata", "0e006e0134a428005b"}, + {"Mi flora pink tuya", "0xfd50", "servicedata", "620000000047640000"}, }; TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{ @@ -771,6 +775,8 @@ TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{ TheengsDecoder::BLE_ID_NUM::TILE, TheengsDecoder::BLE_ID_NUM::TILE, TheengsDecoder::BLE_ID_NUM::TILE, + TheengsDecoder::BLE_ID_NUM::HHCCJCY10, + TheengsDecoder::BLE_ID_NUM::HHCCJCY10, }; // MAC manufacturer data test input [test name] [mac] [data] From cd9524f822863a5d1e7746ff7795a381d720f08a Mon Sep 17 00:00:00 2001 From: DigiH Date: Tue, 4 Apr 2023 16:39:28 +0200 Subject: [PATCH 2/2] Update test_ble.cpp --- tests/BLE/test_ble.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 97116145..8c05535b 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -250,6 +250,7 @@ const char* expected_uuid[] = { "{\"brand\":\"Tile\",\"model\":\"Smart Tracker\",\"model_id\":\"TILE\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"Tile Tracker\"}", "{\"brand\":\"Xiaomi/VegTrug\",\"model\":\"MiFlora\",\"model_id\":\"HHCCJCY10\",\"type\":\"PLANT\",\"tempc\":11,\"tempf\":51.8,\"moi\":14,\"lux\":79012,\"fer\":91,\"batt\":40}", "{\"brand\":\"Xiaomi/VegTrug\",\"model\":\"MiFlora\",\"model_id\":\"HHCCJCY10\",\"type\":\"PLANT\",\"tempc\":0,\"tempf\":32,\"moi\":98,\"lux\":71,\"fer\":0,\"batt\":100}", + "{\"brand\":\"Xiaomi/VegTrug\",\"model\":\"MiFlora\",\"model_id\":\"HHCCJCY10\",\"type\":\"PLANT\",\"tempc\":21,\"tempf\":69.8,\"moi\":96,\"lux\":548,\"fer\":0,\"batt\":100}", }; const char* expected_mac_mfg[] = { @@ -680,6 +681,7 @@ const char* test_uuid[][4] = { {"Tile uuid", "0xfd84", "servicedata", "0200c58aaccd312f479e"}, {"Mi flora pink tuya", "0xfd50", "servicedata", "0e006e0134a428005b"}, {"Mi flora pink tuya", "0xfd50", "servicedata", "620000000047640000"}, + {"Mi flora pink tuya", "0xfd50", "servicedata", "6000d2000224640000"}, }; TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{ @@ -777,6 +779,7 @@ TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{ TheengsDecoder::BLE_ID_NUM::TILE, TheengsDecoder::BLE_ID_NUM::HHCCJCY10, TheengsDecoder::BLE_ID_NUM::HHCCJCY10, + TheengsDecoder::BLE_ID_NUM::HHCCJCY10, }; // MAC manufacturer data test input [test name] [mac] [data]