Skip to content

Commit

Permalink
Modify Shelly BluH&T to include zero value for button property (#598)
Browse files Browse the repository at this point in the history
* Modify SBHT_003C definition to include zero value for button property when the sensor updates on non-button events.

* Modify tests for SBHT to include expected zero-value for button property.
  • Loading branch information
chrestme authored Jan 8, 2025
1 parent 2a8a9cf commit 46a2607
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/devices/SBHT_003C_json.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char* _SBHT_003C_json = "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"tag\":\"0106\",\"condition\":[\"servicedata\",\"=\",20,\"index\",0,\"44\",\"|\",\"servicedata\",\"=\",24,\"index\",0,\"44\",\"&\",\"uuid\",\"index\",0,\"fcd2\",\"&\",\"name\",\"index\",0,\"SBHT-\"],\"properties\":{\"packet\":{\"condition\":[\"servicedata\",2,\"00\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"batt\":{\"condition\":[\"servicedata\",6,\"01\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,2,false,false]},\"hum\":{\"condition\":[\"servicedata\",10,\"2e\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,false]},\"button\":{\"condition\":[\"servicedata\",14,\"3a\"],\"decoder\":[\"string_from_hex_data\",\"servicedata\",16,2],\"lookup\":[\"01\",1,\"fe\",11]},\"tempc\":{\"condition\":[\"servicedata\",14,\"45\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",16,4,true,false],\"post_proc\":[\"/\",10]},\"_tempc\":{\"condition\":[\"servicedata\",18,\"45\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true,false],\"post_proc\":[\"/\",10]},\"mac\":{\"condition\":[\"manufacturerdata\",\"=\",30],\"decoder\":[\"revmac_from_hex_data\",\"manufacturerdata\",18]}}}";
const char* _SBHT_003C_json = "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"tag\":\"0106\",\"condition\":[\"servicedata\",\"=\",20,\"index\",0,\"44\",\"|\",\"servicedata\",\"=\",24,\"index\",0,\"44\",\"&\",\"uuid\",\"index\",0,\"fcd2\",\"&\",\"name\",\"index\",0,\"SBHT-\"],\"properties\":{\"packet\":{\"condition\":[\"servicedata\",2,\"00\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"batt\":{\"condition\":[\"servicedata\",6,\"01\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,2,false,false]},\"hum\":{\"condition\":[\"servicedata\",10,\"2e\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,2,false,false]},\"button\":{\"condition\":[\"servicedata\",14,\"3a\"],\"decoder\":[\"string_from_hex_data\",\"servicedata\",16,2],\"lookup\":[\"01\",1,\"fe\",11]},\"_button\":{\"condition\":[\"servicedata\",14,\"!\",\"3a\"],\"decoder\":[\"static_value\",0]},\"tempc\":{\"condition\":[\"servicedata\",14,\"45\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",16,4,true,false],\"post_proc\":[\"/\",10]},\"_tempc\":{\"condition\":[\"servicedata\",18,\"45\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true,false],\"post_proc\":[\"/\",10]},\"mac\":{\"condition\":[\"manufacturerdata\",\"=\",30],\"decoder\":[\"revmac_from_hex_data\",\"manufacturerdata\",18]}}}";
/*R""""(
{
"brand":"Shelly",
Expand All @@ -25,6 +25,10 @@ const char* _SBHT_003C_json = "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\"
"lookup":["01", 1,
"fe", 11]
},
"_button":{
"condition":["servicedata", 14, "!", "3a"],
"decoder":["static_value", 0]
},
"tempc":{
"condition":["servicedata", 14, "45"],
"decoder":["value_from_hex_data", "servicedata", 16, 4, true, false],
Expand Down
4 changes: 2 additions & 2 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ const char* expected_name_mac_uuid_mfgsvcdata[] = {
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU Motion\",\"model_id\":\"SBMO-003Z\",\"type\":\"CTMO\",\"acts\":true,\"cont\":true,\"packet\":2,\"batt\":100,\"lux\":132,\"motion\":true,\"mac\":\"60:EF:AB:AA:BB:CC\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU Motion\",\"model_id\":\"SBMO-003Z\",\"type\":\"CTMO\",\"acts\":true,\"cont\":true,\"packet\":5,\"batt\":100,\"lux\":36,\"motion\":false,\"mac\":\"60:EF:AB:AA:BB:CC\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU Motion encrypted\",\"model_id\":\"SBMO_003Z_ENCR\",\"type\":\"CTMO\",\"acts\":true,\"cont\":true,\"encr\":2,\"cipher\":\"cc08edf25d61cc0f42b6\",\"ctr\":\"00112233\",\"mic\":\"18cd3624\",\"mac\":\"60:EF:AB:AA:BB:CC\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":78,\"batt\":100,\"hum\":63,\"tempc\":22.3,\"tempf\":72.14,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":78,\"batt\":100,\"hum\":63,\"button\":0,\"tempc\":22.3,\"tempf\":72.14,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":78,\"batt\":100,\"hum\":63,\"button\":1,\"tempc\":22.3,\"tempf\":72.14,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":174,\"batt\":100,\"hum\":56,\"tempc\":25,\"tempf\":77,\"mac\":\"AA:BB:AA:BB:AA:BB\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":174,\"batt\":100,\"hum\":56,\"button\":0,\"tempc\":25,\"tempf\":77,\"mac\":\"AA:BB:AA:BB:AA:BB\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":174,\"batt\":100,\"hum\":56,\"button\":11,\"tempc\":25,\"tempf\":77,\"mac\":\"AA:BB:AA:BB:AA:BB\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T encrypted\",\"model_id\":\"SBHT-003C_ENCR\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"encr\":2,\"cipher\":\"e1a236ace4b4086167\",\"ctr\":\"4bfbd366\",\"mic\":\"8c080c2e\",\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T encrypted\",\"model_id\":\"SBHT-003C_ENCR\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"encr\":2,\"cipher\":\"c85de27369ce3f84750015\",\"ctr\":\"aae9d466\",\"mic\":\"b801349b\",\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
Expand Down

0 comments on commit 46a2607

Please sign in to comment.