Skip to content

Commit

Permalink
Tilt Brewing Hydro- Thermometer (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH authored Apr 25, 2024
1 parent 55e1a4f commit e2f0f3c
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/devices/TILT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tilt Brewing Hydro- Thermometer

|Model Id|[TILT](https://github.com/theengs/decoder/blob/development/src/devices/TILT_json.h)|
|-|-|
|Brand|Tilt|
|Model|Brewing Hydro- Thermometer|
|Short Description|Hydro- Thermometer for beer and cidre brewing|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|CR123A|
|Exchanged Data|color, temperature, specific gravity|
|Encrypted|No|
8 changes: 8 additions & 0 deletions src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,14 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
_key[4] = 'c';
}

/* If the property is tempf in F, make sure to convert and add temp in C */
if (_key.find("tempf", 0, 5) != std::string::npos) {
double tc = jsondata[_key];
_key[4] = 'c';
jsondata[_key] = (tc - 32) * 5 / 9;
_key[4] = 'f';
}

/* If the property is with suffix _cm, make sure to convert and add length in inches */
if (_key.find("_cm", _key.length() - 3, 3) != std::string::npos) {
double tc = jsondata[_key];
Expand Down
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class TheengsDecoder {
BWBSDOO,
BM2,
BM6,
TILT,
RDL52832,
ABN03,
ABN07,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
#include "devices/BWBSDOO_json.h"
#include "devices/BM2_json.h"
#include "devices/BM6_json.h"
#include "devices/TILT_json.h"
#include "devices/JAALEE_json.h"
#include "devices/APPLEWATCH_json.h"
#include "devices/APPLEDEVICE_json.h"
Expand Down Expand Up @@ -190,6 +191,7 @@ const char* _devices[][2] = {
{_BWBSDOO_json, _BWBSDOO_json_props},
{_BM2_json, _BM2_json_props},
{_BM6_json, _BM6_json_props},
{_TILT_json, _TILT_json_props},
{_RDL52832_json, _RDL52832_json_props},
{_ABN03_json, _ABN03_json_props},
{_ABN07_json, _ABN07_json_props},
Expand Down
49 changes: 49 additions & 0 deletions src/devices/TILT_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const char* _TILT_json = "{\"brand\":\"Tilt\",\"model\":\"Brewing Hydro- Thermometer\",\"model_id\":\"TILT\",\"tag\":\"0201\",\"condition\":[\"manufacturerdata\",\"=\",50,\"index\",0,\"4c000215a495bb\",\"&\",\"manufacturerdata\",\"index\",16,\"c5b14b44b5121370f02d74de004403f8c5\"],\"properties\":{\"color\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",14,2],\"lookup\":[\"10\",\"red\",\"20\",\"green\",\"30\",\"black\",\"40\",\"purple\",\"50\",\"orange\",\"60\",\"blue\",\"70\",\"yellow\",\"80\",\"pink\"]},\"tempf\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",40,4,false,true]},\"gravity\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",44,4,false,false],\"post_proc\":[\"/\",1000]}}}";

/*R""""(
{
"brand":"Tilt",
"model":"Brewing Hydro- Thermometer",
"model_id":"TILT",
"tag":"0201",
"condition":["manufacturerdata", "=", 50, "index", 0, "4c000215a495bb", "&", "manufacturerdata", "index", 16, "c5b14b44b5121370f02d74de004403f8c5"],
"properties":{
"color":{
"decoder":["string_from_hex_data", "manufacturerdata", 14, 2],
"lookup":["10", "red",
"20", "green",
"30", "black",
"40", "purple",
"50", "orange",
"60", "blue",
"70", "yellow",
"80", "pink"]
},
"tempf":{
"decoder":["value_from_hex_data", "manufacturerdata", 40, 4, false, true]
},
"gravity":{
"decoder":["value_from_hex_data", "manufacturerdata", 44, 4, false, false],
"post_proc":["/", 1000]
}
}
})"""";*/

const char* _TILT_json_props = "{\"properties\":{\"color\":{\"unit\":\"string\",\"name\":\"color\"},\"tempf\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"gravity\":{\"unit\":\"SG\",\"name\":\"specific_gravity\"}}}";
/*R""""(
{
"properties":{
"color":{
"unit":"string",
"name":"color"
},
"tempf":{
"unit":"°C",
"name":"temperature"
},
"gravity":{
"unit":"SG",
"name":"specific_gravity"
}
}
})"""";*/
7 changes: 5 additions & 2 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const char* expected_mfg[] = {
"{\"brand\":\"Govee\",\"model\":\"Smart Thermo-Hygrometer\",\"model_id\":\"H5100/01/02/04/05/74/77\",\"type\":\"THB\",\"cidc\":false,\"acts\":true,\"tempc\":22.7,\"tempf\":72.86,\"hum\":44.6,\"batt\":100}",
"{\"brand\":\"iTAG\",\"model\":\"Smart Tracker\",\"model_id\":\"ITAG\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"iTAG Tracker\"}",
"{\"brand\":\"iTAG\",\"model\":\"Smart Tracker\",\"model_id\":\"ITAG\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"iTAG Tracker\"}",
"{\"brand\":\"Tilt\",\"model\":\"Brewing Hydro- Thermometer\",\"model_id\":\"TILT\",\"type\":\"THBX\",\"cidc\":false,\"color\":\"red\",\"tempf\":68,\"tempc\":20,\"gravity\":1.016}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -573,8 +574,9 @@ const char* test_mfgdata[][3] = {
{"SwitchBot Meter ManData", "WoSensorTHP", "6909aabbccddeeff3e0908965b"},
{"Gigaset G-Tag", "", "80010215123480c390ffbbc5"},
{"H5105", "GVH5105_1234", "0100010103787664"},
{"Tracker iTAG sesardelaisla ", "iTAG", "0501aabbccddeeff6602010300"},
{"Tracker iTAG sesardelaisla ", "iTAG", "0501ffeeddccbbaa3fa2e2ee00"},
{"Tracker iTAG sesardelaisla", "iTAG", "0501aabbccddeeff6602010300"},
{"Tracker iTAG sesardelaisla", "iTAG", "0501ffeeddccbbaa3fa2e2ee00"},
{"Tilt Hydrothermometer", "Tilt", "4c000215a495bb10c5b14b44b5121370f02d74de004403f8c5"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -711,6 +713,7 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::H5102,
TheengsDecoder::BLE_ID_NUM::ITAG,
TheengsDecoder::BLE_ID_NUM::ITAG,
TheengsDecoder::BLE_ID_NUM::TILT,
};

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

0 comments on commit e2f0f3c

Please sign in to comment.