From ace49f97bba88d62ef95004b3e49dd2a1402a5b5 Mon Sep 17 00:00:00 2001 From: DigiH Date: Sat, 23 Jul 2022 03:25:47 +0200 Subject: [PATCH] SwitchBot Meter alters bits fix --- src/devices/SBMT_json.h | 4 ++-- tests/BLE/test_ble.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/devices/SBMT_json.h b/src/devices/SBMT_json.h index 6a0ff03b..f94f8e3e 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\",6,2,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\":{\"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]}}}"; /*R""""( { "brand":"SwitchBot", @@ -9,7 +9,7 @@ const char* _SBMT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\" "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", 6, 2, false, false], + "decoder":["value_from_hex_data", "servicedata", 7, 1, false, false], "post_proc":["/", 10] }, "tempc":{ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 5b2ac61f..dce93138 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -124,9 +124,9 @@ const char* expected_uuid[] = { "{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"mode\":\"onestate\",\"state\":\"on\",\"batt\":91}", "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":25.8,\"tempf\":78.44,\"hum\":59,\"batt\":58}", "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":-25.3,\"tempf\":-13.54,\"hum\":56,\"batt\":58}", - "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":26,\"tempf\":78.8,\"hum\":56,\"batt\":58}", - "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":25,\"tempf\":77,\"hum\":56,\"batt\":84}", - "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":25,\"tempf\":77,\"hum\":56,\"batt\":84}", + "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":26.7,\"tempf\":80.06,\"hum\":56,\"batt\":58}", + "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":25.5,\"tempf\":77.9,\"hum\":56,\"batt\":84}", + "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":25.2,\"tempf\":77.36,\"hum\":56,\"batt\":84}", "{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"tempc\":25.6,\"tempf\":78.08,\"hum\":90.00076295,\"moi\":49.99923705,\"volt\":3.1}", "{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"tempc\":22.7,\"tempf\":72.86,\"hum\":65.00038148,\"moi\":42.00045777,\"lux\":12500,\"volt\":2.95}", "{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"tempc\":25.6,\"tempf\":78.08,\"hum\":90.00076295,\"moi\":49.99923705,\"volt\":3.1}", @@ -361,11 +361,11 @@ const char* test_uuid[][4] = { {"Switchbot_S1", "0d00", "servicedata", "48d0db"}, {"Switchbot_S1", "0d00", "servicedata", "4890cc"}, {"Switchbot_S1", "0d00", "servicedata", "48005b"}, - {"Switchbot_Meter_Plus", "fd3d", "servicedata", "6900ba08993b"}, + {"Switchbot_Meter_Plus", "fd3d", "servicedata", "6900ba18993b"}, {"Switchbot_Meter_Plus", "fd3d", "servicedata", "6900ba031938"}, - {"Switchbot_Meter_Plus", "fd3d", "servicedata", "6900ba009ab8"}, - {"Switchbot_Meter", "0d00", "servicedata", "540054009938"}, - {"Switchbot_Meter", "0d00", "servicedata", "5400d40099b8"}, + {"Switchbot_Meter_Plus", "fd3d", "servicedata", "6900ba379ab8"}, + {"Switchbot_Meter", "0d00", "servicedata", "540054459938"}, + {"Switchbot_Meter", "0d00", "servicedata", "5400d40299b8"}, {"bParasite", "181a", "servicedata", "10c30c1c6400e6667fffaabbccddeeff"}, {"bParasite", "181a", "servicedata", "11c30b8658aca6666b85aabbccddeeff30d4"}, {"bParasite", "181a", "servicedata", "20c30c1c0a00e6667fffaabbccddeeff"},