Skip to content

Commit

Permalink
masking optimisation (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH authored Jul 29, 2022
1 parent b752cfc commit 0bf131b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 41 deletions.
9 changes: 2 additions & 7 deletions src/devices/SBCS_json.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char* _SBCS_json = "{\"brand\":\"SwitchBot\",\"model\":\"Contact Sensor\",\"model_id\":\"W120150X\",\"condition\":[\"servicedata\",\"=\",18,\"index\",0,\"64\",\"&\",\"uuid\",\"index\",0,\"0d00\"],\"properties\":{\"contact\":{\"condition\":[\"servicedata\",7,\"bit\",2,0],\"decoder\":[\"bit_static_value\",\"servicedata\",7,1,\"closed\",\"open\"]},\"_contact\":{\"condition\":[\"servicedata\",7,\"bit\",2,1],\"decoder\":[\"static_value\",\"timeout not closed\"]},\"movement\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,false,true]},\"lightlevel\":{\"decoder\":[\"bit_static_value\",\"servicedata\",7,0,\"dark\",\"bright\"]},\"scopetested\":{\"condition\":[\"servicedata\",2,\"bit\",3,0],\"decoder\":[\"static_value\",false]},\"batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"_batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"-\",128]}}}";
const char* _SBCS_json = "{\"brand\":\"SwitchBot\",\"model\":\"Contact Sensor\",\"model_id\":\"W120150X\",\"condition\":[\"servicedata\",\"=\",18,\"index\",0,\"64\",\"&\",\"uuid\",\"index\",0,\"0d00\"],\"properties\":{\"contact\":{\"condition\":[\"servicedata\",7,\"bit\",2,0],\"decoder\":[\"bit_static_value\",\"servicedata\",7,1,\"closed\",\"open\"]},\"_contact\":{\"condition\":[\"servicedata\",7,\"bit\",2,1],\"decoder\":[\"static_value\",\"timeout not closed\"]},\"movement\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,false,true]},\"lightlevel\":{\"decoder\":[\"bit_static_value\",\"servicedata\",7,0,\"dark\",\"bright\"]},\"scopetested\":{\"condition\":[\"servicedata\",2,\"bit\",3,0],\"decoder\":[\"static_value\",false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]}}}";
/*R""""(
{
"brand":"SwitchBot",
Expand All @@ -25,13 +25,8 @@ const char* _SBCS_json = "{\"brand\":\"SwitchBot\",\"model\":\"Contact Sensor\",
"decoder":["static_value", false]
},
"batt":{
"condition":["servicedata", 4, "bit", 3, 0],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false]
},
"_batt":{
"condition":["servicedata", 4, "bit", 3, 1],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false],
"post_proc":["-", 128]
"post_proc":["&", 127]
}
}
})"""";*/
Expand Down
9 changes: 2 additions & 7 deletions src/devices/SBCU_json.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char* _SBCU_json = "{\"brand\":\"SwitchBot\",\"model\":\"Curtain\",\"model_id\":\"W070160X\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"&\",\"servicedata\",\"=\",10,\"index\",0,\"63\"],\"properties\":{\"motion\":{\"decoder\":[\"bit_static_value\",\"servicedata\",6,3,false,true]},\"position\":{\"condition\":[\"servicedata\",6,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,2,false,false]},\"_position\":{\"condition\":[\"servicedata\",6,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,2,false,false],\"post_proc\":['-',128]},\"calibrated\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,false,true]},\"lightlevel\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,1,false,false]},\"batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"_batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"-\",128]}}}";
const char* _SBCU_json = "{\"brand\":\"SwitchBot\",\"model\":\"Curtain\",\"model_id\":\"W070160X\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"&\",\"servicedata\",\"=\",10,\"index\",0,\"63\"],\"properties\":{\"motion\":{\"decoder\":[\"bit_static_value\",\"servicedata\",6,3,false,true]},\"position\":{\"condition\":[\"servicedata\",6,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,2,false,false]},\"_position\":{\"condition\":[\"servicedata\",6,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",6,2,false,false],\"post_proc\":['-',128]},\"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",
Expand All @@ -25,13 +25,8 @@ const char* _SBCU_json = "{\"brand\":\"SwitchBot\",\"model\":\"Curtain\",\"model
"decoder":["value_from_hex_data", "servicedata", 8, 1, false, false]
},
"batt":{
"condition":["servicedata", 4, "bit", 3, 0],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false]
},
"_batt":{
"condition":["servicedata", 4, "bit", 3, 1],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false],
"post_proc":["-", 128]
"post_proc":["&", 127]
}
}
})"""";*/
Expand Down
9 changes: 2 additions & 7 deletions src/devices/SBMS_json.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char* _SBMS_json = "{\"brand\":\"SwitchBot\",\"model\":\"Motion Sensor\",\"model_id\":\"W110150X\",\"condition\":[\"servicedata\",\"=\",12,\"index\",0,\"73\",\"&\",\"uuid\",\"index\",0,\"0d00\"],\"properties\":{\"movement\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,false,true]},\"led\":{\"decoder\":[\"bit_static_value\",\"servicedata\",10,1,false,true]},\"scopetested\":{\"condition\":[\"servicedata\",2,\"bit\",3,0],\"decoder\":[\"static_value\",false]},\"sensingdistance\":{\"condition\":[\"servicedata\",11,\"bit\",3,0,\"&\",\"servicedata\",11,\"bit\",2,0],\"decoder\":[\"static_value\",\"long\"]},\"_sensingdistance\":{\"condition\":[\"servicedata\",11,\"bit\",3,0,\"&\",\"servicedata\",11,\"bit\",2,1],\"decoder\":[\"static_value\",\"middle\"]},\"__sensingdistance\":{\"condition\":[\"servicedata\",11,\"bit\",3,1,\"&\",\"servicedata\",11,\"bit\",2,0],\"decoder\":[\"static_value\",\"short\"]},\"lightlevel\":{\"condition\":[\"servicedata\",11,\"bit\",1,0,\"&\",\"servicedata\",11,\"bit\",0,1],\"decoder\":[\"static_value\",\"dark\"]},\"_lightlevel\":{\"condition\":[\"servicedata\",11,\"bit\",1,1,\"&\",\"servicedata\",11,\"bit\",0,0],\"decoder\":[\"static_value\",\"bright\"]},\"batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"_batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"-\",128]}}}";
const char* _SBMS_json = "{\"brand\":\"SwitchBot\",\"model\":\"Motion Sensor\",\"model_id\":\"W110150X\",\"condition\":[\"servicedata\",\"=\",12,\"index\",0,\"73\",\"&\",\"uuid\",\"index\",0,\"0d00\"],\"properties\":{\"movement\":{\"decoder\":[\"bit_static_value\",\"servicedata\",2,2,false,true]},\"led\":{\"decoder\":[\"bit_static_value\",\"servicedata\",10,1,false,true]},\"scopetested\":{\"condition\":[\"servicedata\",2,\"bit\",3,0],\"decoder\":[\"static_value\",false]},\"sensingdistance\":{\"condition\":[\"servicedata\",11,\"bit\",3,0,\"&\",\"servicedata\",11,\"bit\",2,0],\"decoder\":[\"static_value\",\"long\"]},\"_sensingdistance\":{\"condition\":[\"servicedata\",11,\"bit\",3,0,\"&\",\"servicedata\",11,\"bit\",2,1],\"decoder\":[\"static_value\",\"middle\"]},\"__sensingdistance\":{\"condition\":[\"servicedata\",11,\"bit\",3,1,\"&\",\"servicedata\",11,\"bit\",2,0],\"decoder\":[\"static_value\",\"short\"]},\"lightlevel\":{\"condition\":[\"servicedata\",11,\"bit\",1,0,\"&\",\"servicedata\",11,\"bit\",0,1],\"decoder\":[\"static_value\",\"dark\"]},\"_lightlevel\":{\"condition\":[\"servicedata\",11,\"bit\",1,1,\"&\",\"servicedata\",11,\"bit\",0,0],\"decoder\":[\"static_value\",\"bright\"]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]}}}";
/*R""""(
{
"brand":"SwitchBot",
Expand Down Expand Up @@ -37,13 +37,8 @@ const char* _SBMS_json = "{\"brand\":\"SwitchBot\",\"model\":\"Motion Sensor\",\
"decoder":["static_value", "bright"]
},
"batt":{
"condition":["servicedata", 4, "bit", 3, 0],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false]
},
"_batt":{
"condition":["servicedata", 4, "bit", 3, 1],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false],
"post_proc":["-", 128]
"post_proc":["&", 127]
}
}
})"""";*/
Expand Down
16 changes: 3 additions & 13 deletions src/devices/SBMT_json.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common_props.h"

const char* _SBMT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"condition\":[\"servicedata\",\"=\",12,\"index\",0,\"54\",\"|\",\"servicedata\",\"=\",12,\"index\",0,\"69\",\"&\",\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\"],\"properties\":{\".cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",7,1,false,false],\"post_proc\":[\"/\",10]},\"tempc\":{\"condition\":[\"servicedata\",8,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,2,true,false],\"post_proc\":[\"+\",\".cal\",\"*\",-1]},\"_tempc\":{\"condition\":[\"servicedata\",8,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,2,true,false],\"post_proc\":[\"+\",\".cal\",\"-\",128]},\"hum\":{\"condition\":[\"servicedata\",10,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",10,2,false,false]},\"_hum\":{\"condition\":[\"servicedata\",10,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",10,2,false,false],\"post_proc\":[\"-\",128]},\"batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"_batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"-\",128]}}}";
const char* _SBMT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"condition\":[\"servicedata\",\"=\",12,\"index\",0,\"54\",\"|\",\"servicedata\",\"=\",12,\"index\",0,\"69\",\"&\",\"uuid\",\"index\",0,\"0d00\",\"|\",\"uuid\",\"index\",0,\"fd3d\"],\"properties\":{\".cal\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",7,1,false,false],\"post_proc\":[\"/\",10]},\"tempc\":{\"condition\":[\"servicedata\",8,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,2,true,false],\"post_proc\":[\"+\",\".cal\",\"*\",-1]},\"_tempc\":{\"condition\":[\"servicedata\",8,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,2,true,false],\"post_proc\":[\"+\",\".cal\",\"-\",128]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",10,2,false,false],\"post_proc\":[\"&\",127]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]}}}";
/*R""""(
{
"brand":"SwitchBot",
Expand All @@ -23,22 +23,12 @@ const char* _SBMT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"
"post_proc":["+", ".cal", "-", 128]
},
"hum":{
"condition":["servicedata", 10, "bit", 3, 0],
"decoder":["value_from_hex_data", "servicedata", 10, 2, false, false]
},
"_hum":{
"condition":["servicedata", 10, "bit", 3, 1],
"decoder":["value_from_hex_data", "servicedata", 10, 2, false, false],
"post_proc":["-", 128]
"post_proc":["&", 127]
},
"batt":{
"condition":["servicedata", 4, "bit", 3, 0],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false]
},
"_batt":{
"condition":["servicedata", 4, "bit", 3, 1],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false],
"post_proc":["-", 128]
"post_proc":["&", 127]
}
}
})"""";*/
Expand Down
9 changes: 2 additions & 7 deletions src/devices/SBS1_json.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char* _SBS1_json = "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"&\",\"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\":{\"condition\":[\"servicedata\",4,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"_batt\":{\"condition\":[\"servicedata\",4,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"-\",128]}}}";
const char* _SBS1_json = "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"&\",\"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",
Expand All @@ -13,13 +13,8 @@ const char* _SBS1_json = "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\
"decoder":["bit_static_value", "servicedata", 2, 2, "on", "off"]
},
"batt":{
"condition":["servicedata", 4, "bit", 3, 0],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false]
},
"_batt":{
"condition":["servicedata", 4, "bit", 3, 1],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false],
"post_proc":["-", 128]
"post_proc":["&", 127]
}
}
})"""";*/
Expand Down

0 comments on commit 0bf131b

Please sign in to comment.