Skip to content

Commit

Permalink
ADD "ctrl" tag for controllable devices/actuators
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Sep 6, 2024
1 parent e71f565 commit e93536c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 31 deletions.
10 changes: 7 additions & 3 deletions docs/participate/adding-decoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ Each device should also have an encoded **tag** property to, at the minimum, def
<td rowspan=1>255 - UNIQ - unique devices</td>
</tr>
<tr>
<td rowspan=6>Byte[1]</td>
<td rowspan=6>Additional properties</td>
<td rowspan=1>Bits[7-5] - Reserved</td>
<td rowspan=8>Byte[1]</td>
<td rowspan=8>Additional properties</td>
<td rowspan=1>Bits[7-6] - Reserved</td>
</tr>
<tr>
<td rowspan=1>Bit[5] Devices/actuators which are controllable > "ctrl":</td>
</tr>
<tr>
<tr>
<td rowspan=1>Bit[4] Potential RMAC device - if not defined with Identity MAC and IRK in Theengs Gateway > "prmac":</td>
</tr>
Expand Down
6 changes: 6 additions & 0 deletions src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,12 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
doc["prmac"] = true;
jsondata["prmac"] = doc["prmac"];
}

if (((data >> 1) & 0x01) == 1) { // CTRL - Controllable device/actuator
doc.add("ctrl");
doc["ctrl"] = true;
jsondata["ctrl"] = doc["ctrl"];
}
}

// Octet Byte[2] - Encryption Model
Expand Down
4 changes: 2 additions & 2 deletions src/devices/SBBT_json.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const char* _SBBT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Blind Tilt\",\"model_id\":\"W270160X\",\"tag\":\"0d02\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\",\"&\",\"servicedata\",\"=\",6,\"index\",0,\"78\",\"&\",\"manufacturerdata\",\">=\",24,\"index\",0,\"6909\"],\"properties\":{\"open\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,2,false,false],\"post_proc\":[\"&\",127,\"-\",50,\"*\",2,\"±\",100,\"abs\"]},\"direction\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,2,false,false],\"post_proc\":[\"&\",127,\"-\",50,\"*\",2,\"SBBT-dir\"]},\"motion\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",20,3,false,true]},\"calibrated\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",19,0,false,true]},\"lightlevel\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",18,1,false,false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"mac_from_hex_data\",\"manufacturerdata\",4]}}}";
const char* _SBBT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Blind Tilt\",\"model_id\":\"W270160X\",\"tag\":\"0d22\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\",\"&\",\"servicedata\",\"=\",6,\"index\",0,\"78\",\"&\",\"manufacturerdata\",\">=\",24,\"index\",0,\"6909\"],\"properties\":{\"open\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,2,false,false],\"post_proc\":[\"&\",127,\"-\",50,\"*\",2,\"±\",100,\"abs\"]},\"direction\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,2,false,false],\"post_proc\":[\"&\",127,\"-\",50,\"*\",2,\"SBBT-dir\"]},\"motion\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",20,3,false,true]},\"calibrated\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",19,0,false,true]},\"lightlevel\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",18,1,false,false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"mac_from_hex_data\",\"manufacturerdata\",4]}}}";
/*R""""(
{
"brand":"SwitchBot",
"model":"Blind Tilt",
"model_id":"W270160X",
"tag":"0d02",
"tag":"0d22",
"condition":["uuid", "index", 0, "0d00", "|", "uuid", "index", 0, "fd3d", "&", "servicedata", "=", 6, "index", 0, "78", "&", "manufacturerdata", ">=", 24, "index", 0, "6909"],
"properties":{
"open":{
Expand Down
4 changes: 2 additions & 2 deletions src/devices/SBCU_json.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const char* _SBCU_json = "{\"brand\":\"SwitchBot\",\"model\":\"Curtain (2/3)\",\"model_id\":\"W070160X\",\"tag\":\"0d02\",\"condition\":[\"servicedata\",\"=\",10,\"index\",0,\"63\",\"|\",\"servicedata\",\"=\",12,\"index\",0,\"63\",\"|\",\"servicedata\",\"=\",12,\"index\",0,\"7b\",\"&\",[\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\"]],\"properties\":{\"moving\":{\"decoder\":[\"bit_static_value\",\"servicedata\",6,3,false,true]},\"position\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,2,false,false],\"post_proc\":[\"&\",127]},\"calibrated\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,false,true]},\"lightlevel\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,1,false,false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]}}}";
const char* _SBCU_json = "{\"brand\":\"SwitchBot\",\"model\":\"Curtain (2/3)\",\"model_id\":\"W070160X\",\"tag\":\"0d22\",\"condition\":[\"servicedata\",\"=\",10,\"index\",0,\"63\",\"|\",\"servicedata\",\"=\",12,\"index\",0,\"63\",\"|\",\"servicedata\",\"=\",12,\"index\",0,\"7b\",\"&\",[\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\"]],\"properties\":{\"moving\":{\"decoder\":[\"bit_static_value\",\"servicedata\",6,3,false,true]},\"position\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,2,false,false],\"post_proc\":[\"&\",127]},\"calibrated\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,false,true]},\"lightlevel\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,1,false,false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]}}}";
/*R""""(
{
"brand":"SwitchBot",
"model":"Curtain (2/3)",
"model_id":"W070160X",
"tag":"0d02",
"tag":"0d22",
"condition":["servicedata", "=", 10, "index", 0, "63", "|", "servicedata", "=", 12, "index", 0, "63", "|", "servicedata", "=", 12, "index", 0, "7b", "&", ["uuid", "index", 0, "0d00", "|", "uuid", "index", 0, "fd3d"]],
"properties":{
"moving":{
Expand Down
4 changes: 2 additions & 2 deletions src/devices/SBS1_json.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const char* _SBS1_json = "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"tag\":\"0e02\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\",\"&\",\"servicedata\",\">=\",6,\"index\",0,\"48\"],\"properties\":{\"mode\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,3,\"onestate\",\"on/off\"]},\"state\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,\"on\",\"off\"]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]}}}";
const char* _SBS1_json = "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"tag\":\"0e22\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\",\"&\",\"servicedata\",\">=\",6,\"index\",0,\"48\"],\"properties\":{\"mode\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,3,\"onestate\",\"on/off\"]},\"state\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,\"on\",\"off\"]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]}}}";
/*R""""(
{
"brand":"SwitchBot",
"model":"Bot",
"model_id":"X1",
"tag":"0e02",
"tag":"0e22",
"condition":["uuid", "index", 0, "0d00", "|", "uuid", "index", 0, "fd3d", "&", "servicedata", ">=", 6, "index", 0, "48"],
"properties":{
"mode":{
Expand Down
Loading

0 comments on commit e93536c

Please sign in to comment.