From 0bf131bbbc152b02a0f59e881bec3861a188591f Mon Sep 17 00:00:00 2001 From: DigiH Date: Fri, 29 Jul 2022 06:02:04 +0200 Subject: [PATCH] masking optimisation (#168) --- src/devices/SBCS_json.h | 9 ++------- src/devices/SBCU_json.h | 9 ++------- src/devices/SBMS_json.h | 9 ++------- src/devices/SBMT_json.h | 16 +++------------- src/devices/SBS1_json.h | 9 ++------- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/src/devices/SBCS_json.h b/src/devices/SBCS_json.h index ac6d463c..b8e29503 100644 --- a/src/devices/SBCS_json.h +++ b/src/devices/SBCS_json.h @@ -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", @@ -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] } } })"""";*/ diff --git a/src/devices/SBCU_json.h b/src/devices/SBCU_json.h index 1395059f..0657c57a 100644 --- a/src/devices/SBCU_json.h +++ b/src/devices/SBCU_json.h @@ -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", @@ -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] } } })"""";*/ diff --git a/src/devices/SBMS_json.h b/src/devices/SBMS_json.h index a78ce954..49af08a4 100644 --- a/src/devices/SBMS_json.h +++ b/src/devices/SBMS_json.h @@ -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", @@ -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] } } })"""";*/ diff --git a/src/devices/SBMT_json.h b/src/devices/SBMT_json.h index f94f8e3e..e690e49d 100644 --- a/src/devices/SBMT_json.h +++ b/src/devices/SBMT_json.h @@ -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", @@ -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] } } })"""";*/ diff --git a/src/devices/SBS1_json.h b/src/devices/SBS1_json.h index e42163ef..c9129421 100644 --- a/src/devices/SBS1_json.h +++ b/src/devices/SBS1_json.h @@ -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", @@ -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] } } })"""";*/