diff --git a/docs/participate/adding-decoders.md b/docs/participate/adding-decoders.md
index 4f3e3475..56dbb416 100644
--- a/docs/participate/adding-decoders.md
+++ b/docs/participate/adding-decoders.md
@@ -53,8 +53,8 @@ Each device should also have an encoded **tag** property to, at the minimum, def
- | Byte[0] |
- Device Type > "type": |
+ Byte[0] |
+ Device Type > "type": |
0 - Reserved |
@@ -115,7 +115,10 @@ Each device should also have an encoded **tag** property to, at the minimum, def
| 19 - WIND - wind speed anemometers |
- | 20-253 - Reserved |
+ 20 - ENRG - energy producing, monitoring and storing devices |
+
+
+ | 20-253 - Reserved for future use |
| 254 - RMAC - known random MAC address devices |
@@ -148,13 +151,16 @@ Each device should also have an encoded **tag** property to, at the minimum, def
Bit[0] Is NOT Company ID compliant > "cidc": |
- | Byte[2] |
- Encryption Model > "encr": |
+ Byte[2] |
+ Encryption Model > "encr": |
1 - LYWSD03MMC PVVX |
| 2 - BTHome v2 |
+
+ | 3 - Victron Energy |
+
diff --git a/src/decoder.cpp b/src/decoder.cpp
index 04e3ffcb..7e19ac7a 100644
--- a/src/decoder.cpp
+++ b/src/decoder.cpp
@@ -584,10 +584,13 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
doc["type"] = "BTN"; // Button
break;
case 18:
- doc["type"] = "AUDIO"; // Button
+ doc["type"] = "AUDIO"; // Audio
break;
case 19:
- doc["type"] = "WIND"; // Button
+ doc["type"] = "WIND"; // Anemometers
+ break;
+ case 20:
+ doc["type"] = "ENRG"; // Energy
break;
case 254:
doc["type"] = "RMAC"; // random MAC address devices
diff --git a/src/decoder.h b/src/decoder.h
index 10b7ce87..666b5af8 100644
--- a/src/decoder.h
+++ b/src/decoder.h
@@ -165,6 +165,8 @@ class TheengsDecoder {
SPHT,
SERVICE_DATA,
UT363BT,
+ VICTSBP_ENCR,
+ VICTSBP,
SE_RHT,
SE_TEMP,
SE_TPROBE,
diff --git a/src/devices.h b/src/devices.h
index 66e23d43..6c9704d1 100644
--- a/src/devices.h
+++ b/src/devices.h
@@ -115,6 +115,8 @@
#include "devices/SensorP_HT_json.h"
#include "devices/ServiceData_json.h"
#include "devices/UT363BT_json.h"
+#include "devices/VICTRON_DCDC_ENCR_json.h"
+#include "devices/VICTRON_DCDC_json.h"
#include "devices/SE_RHT_json.h"
#include "devices/SE_TEMP_json.h"
#include "devices/SE_TPROBE_json.h"
@@ -251,6 +253,8 @@ const char* _devices[][2] = {
{_SensorPush_HT_json, _SensorPush_HT_json_props},
{_ServiceData_json, _ServiceData_json_props},
{_UT363BT_json, _UT363BT_json_props},
+ {_VICTSBP_ENCR_json, _VICTSBP_ENCR_json_props},
+ {_VICTSBP_json, _VICTSBP_json_props},
{_SE_RHT_json, _SE_RHT_json_props},
{_SE_TEMP_json, _SE_TEMP_json_props},
{_SE_TPROBE_json, _SE_TPROBE_json_props},
diff --git a/src/devices/VICTRON_DCDC_ENCR_json.h b/src/devices/VICTRON_DCDC_ENCR_json.h
new file mode 100644
index 00000000..037a3ed2
--- /dev/null
+++ b/src/devices/VICTRON_DCDC_ENCR_json.h
@@ -0,0 +1,39 @@
+const char* _VICTSBP_ENCR_json = "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect encrypted\",\"model_id\":\"VICTSBP_ENCR\",\"tag\":\"140003\",\"condition\":[\"manufacturerdata\",\"=\",50,\"index\",0,\"e10210\",\"&\",\"manufacturerdata\",\"index\",12,\"09\"],\"properties\":{\"cipher\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",20,30]},\"ctr\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",14,4,true]},\"mic\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",18,2]}}}";
+/*R""""(
+{
+ "brand":"Victron Energy",
+ "model":"Smart BatteryProtect encrypted",
+ "model_id":"VICTSBP_ENCR",
+ "tag":"140003",
+ "condition":["manufacturerdata", "=", 50, "index", 0, "e10210", "&", "manufacturerdata", "index", 12, "09"],
+ "properties":{
+ "cipher":{
+ "decoder":["string_from_hex_data", "manufacturerdata", 20, 30]
+ },
+ "ctr":{
+ "decoder":["string_from_hex_data", "manufacturerdata", 14, 4, true]
+ },
+ "mic":{
+ "decoder":["string_from_hex_data", "manufacturerdata", 18, 2]
+ }
+ }
+})"""";*/
+
+const char* _VICTSBP_ENCR_json_props = "{\"properties\":{\"cipher\":{\"unit\":\"hex\",\"name\":\"ciphertext\"},\"ctr\":{\"unit\":\"hex\",\"name\":\"counter\"},\"mic\":{\"unit\":\"hex\",\"name\":\"message integrity check\"}}}";
+/*R""""(
+{
+ "properties":{
+ "cipher":{
+ "unit":"hex",
+ "name":"ciphertext"
+ },
+ "ctr":{
+ "unit":"hex",
+ "name":"counter"
+ },
+ "mic":{
+ "unit":"hex",
+ "name":"message integrity check"
+ }
+ }
+})"""";*/
diff --git a/src/devices/VICTRON_DCDC_json.h b/src/devices/VICTRON_DCDC_json.h
new file mode 100644
index 00000000..c8094c78
--- /dev/null
+++ b/src/devices/VICTRON_DCDC_json.h
@@ -0,0 +1,111 @@
+const char* _VICTSBP_json = "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"tag\":\"1400\",\"condition\":[\"manufacturerdata\",\"=\",50,\"index\",0,\"e10211\",\"&\",\"manufacturerdata\",\"index\",12,\"09ffff\"],\"properties\":{\"device_state\":{\"condition\":[\"manufacturerdata\",20,\"!\",\"ff\"],\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",20,2],\"lookup\":[\"00\",\"off\",\"01\",\"low power\",\"02\",\"fault\",\"03\",\"bulk\",\"04\",\"absorption\",\"05\",\"float\",\"06\",\"storage\",\"07\",\"equalize manual\",\"09\",\"inverting\",\"0b\",\"power_supply\",\"f5\",\"starting up\",\"f6\",\"repeated absorption\",\"f7\",\"recondition\",\"f8\",\"battery safe\",\"f9\",\"active\",\"fc\",\"external control\"]},\"output_state\":{\"condition\":[\"manufacturerdata\",22,\"!\",\"ff\"],\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",22,2],\"lookup\":[\"00\",\"off\",\"01\",\"on\"]},\"error_code\":{\"condition\":[\"manufacturerdata\",24,\"!\",\"ff\",\"&\",\"manufacturerdata\",24,\"!\",\"00\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,2]},\"alarm_reason\":{\"condition\":[\"manufacturerdata\",26,\"!\",\"0000\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",26,4]},\"warning_reason\":{\"condition\":[\"manufacturerdata\",30,\"!\",\"0000\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",30,4]},\"volt_in\":{\"condition\":[\"manufacturerdata\",34,\"!\",\"7fff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",34,4,true,true],\"post_proc\":[\"/\",100]},\"volt_out\":{\"condition\":[\"manufacturerdata\",38,\"!\",\"7fff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",38,4,true,false],\"post_proc\":[\"/\",100]},\"off_reason\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",42,8],\"lookup\":[\"00000000\",\"NO_REASON\",\"01000000\",\"NO_INPUT_POWER\",\"02000000\",\"SWITCHED_OFF_SWITCH\",\"04000000\",\"SWITCHED_OFF_REGISTER\",\"08000000\",\"REMOTE_INPUT\",\"10000000\",\"PROTECTION_ACTIVE\",\"20000000\",\"PAY_AS_YOU_GO_OUT_OF_CREDIT\",\"40000000\",\"BMS\",\"80000000\",\"ENGINE_SHUTDOWN\",\"00010000\",\"ANALYSING_INPUT_VOLTAGE\"]}}}";
+/*R""""(
+{
+ "brand":"Victron Energy",
+ "model":"Smart BatteryProtect",
+ "model_id":"VICTSBP",
+ "tag":"1400",
+ "condition":["manufacturerdata", "=", 50, "index", 0, "e10211", "&", "manufacturerdata", "index", 12, "09ffff"],
+ "properties":{
+ "device_state":{
+ "condition":["manufacturerdata", 20, "!", "ff"],
+ "decoder":["string_from_hex_data", "manufacturerdata", 20, 2],
+ "lookup":["00", "off",
+ "01", "low power",
+ "02", "fault",
+ "03", "bulk",
+ "04", "absorption",
+ "05", "float",
+ "06", "storage",
+ "07", "equalize manual",
+ "09", "inverting",
+ "0b", "power_supply",
+ "f5", "starting up",
+ "f6", "repeated absorption",
+ "f7", "recondition",
+ "f8", "battery safe",
+ "f9", "active",
+ "fc", "external control"]
+ },
+ "output_state":{
+ "condition":["manufacturerdata", 22, "!", "ff"],
+ "decoder":["string_from_hex_data", "manufacturerdata", 22, 2],
+ "lookup":["00", "off",
+ "01", "on"]
+ },
+ "error_code":{
+ "condition":["manufacturerdata", 24, "!", "ff", "&", "manufacturerdata", 24, "!", "00"],
+ "decoder":["value_from_hex_data", "manufacturerdata", 24, 2]
+ },
+ "alarm_reason":{
+ "condition":["manufacturerdata", 26, "!", "0000"],
+ "decoder":["value_from_hex_data", "manufacturerdata", 26, 4]
+ },
+ "warning_reason":{
+ "condition":["manufacturerdata", 30, "!", "0000"],
+ "decoder":["value_from_hex_data", "manufacturerdata", 30, 4]
+ },
+ "volt_in":{
+ "condition":["manufacturerdata", 34, "!", "7fff"],
+ "decoder":["value_from_hex_data", "manufacturerdata", 34, 4, true, true],
+ "post_proc":["/", 100]
+ },
+ "volt_out":{
+ "condition":["manufacturerdata", 38, "!", "7fff"],
+ "decoder":["value_from_hex_data", "manufacturerdata", 38, 4, true, false],
+ "post_proc":["/", 100]
+ },
+ "off_reason":{
+ "decoder":["string_from_hex_data", "manufacturerdata", 42, 8],
+ "lookup":["00000000", "NO_REASON",
+ "01000000", "NO_INPUT_POWER",
+ "02000000", "SWITCHED_OFF_SWITCH",
+ "04000000", "SWITCHED_OFF_REGISTER",
+ "08000000", "REMOTE_INPUT",
+ "10000000", "PROTECTION_ACTIVE",
+ "20000000", "PAY_AS_YOU_GO_OUT_OF_CREDIT",
+ "40000000", "BMS",
+ "80000000", "ENGINE_SHUTDOWN",
+ "00010000", "ANALYSING_INPUT_VOLTAGE"]
+ }
+ }
+})"""";*/
+
+const char* _VICTSBP_json_props = "{\"properties\":{\"device_state\":{\"unit\":\"string\",\"name\":\"device state\"},\"output_state\":{\"unit\":\"string\",\"name\":\"output state\"},\"error_code\":{\"unit\":\"int\",\"name\":\"error code\"},\"alarm_reason\":{\"unit\":\"int\",\"name\":\"alarm reason\"},\"warning_reason\":{\"unit\":\"int\",\"name\":\"warning reason\"},\"volt_in\":{\"unit\":\"V\",\"name\":\"voltage\"},\"volt_out\":{\"unit\":\"V\",\"name\":\"voltage\"},\"off_reason\":{\"unit\":\"string\",\"name\":\"off reason\"}}}";
+/*R""""(
+{
+ "properties":{
+ "device_state":{
+ "unit":"string",
+ "name":"device state"
+ },
+ "output_state":{
+ "unit":"string",
+ "name":"output state"
+ },
+ "error_code":{
+ "unit":"int",
+ "name":"error code"
+ },
+ "alarm_reason":{
+ "unit":"int",
+ "name":"alarm reason"
+ },
+ "warning_reason":{
+ "unit":"int",
+ "name":"warning reason"
+ },
+ "volt_in": {
+ "unit": "V",
+ "name": "voltage"
+ },
+ "volt_out": {
+ "unit": "V",
+ "name": "voltage"
+ },
+ "off_reason":{
+ "unit":"string",
+ "name":"off reason"
+ }
+ }
+})"""";*/
diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp
index f1dc3915..b0212d22 100644
--- a/tests/BLE/test_ble.cpp
+++ b/tests/BLE/test_ble.cpp
@@ -203,6 +203,13 @@ const char* expected_mfg[] = {
"{\"brand\":\"Govee\",\"model\":\"Bluetooth BBQ Thermometer\",\"model_id\":\"H5055\",\"type\":\"BBQ\",\"cidc\":false,\"tempc5\":21,\"tempf5\":69.8,\"tempc6\":21,\"tempf6\":69.8,\"batt\":100}",
"{\"brand\":\"Govee\",\"model\":\"Bluetooth BBQ Thermometer\",\"model_id\":\"H5055\",\"type\":\"BBQ\",\"cidc\":false,\"tempc3\":23,\"tempf3\":73.4,\"tempc4\":21,\"tempf4\":69.8,\"batt\":100}",
"{\"brand\":\"Govee\",\"model\":\"Bluetooth BBQ Thermometer\",\"model_id\":\"H5055\",\"type\":\"BBQ\",\"cidc\":false,\"tempc1\":26,\"tempf1\":78.8,\"tempc2\":22,\"tempf2\":71.6,\"batt\":100}",
+ "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect encrypted\",\"model_id\":\"VICTSBP_ENCR\",\"type\":\"ENRG\",\"encr\":3,\"cipher\":\"f581a6631c3ddfccaa081fad4da6f4\",\"ctr\":\"a82c\",\"mic\":\"da\"}",
+ "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"type\":\"ENRG\",\"device_state\":\"off\",\"output_state\":\"off\",\"volt_in\":12.8,\"volt_out\":0.1,\"off_reason\":\"REMOTE_INPUT\"}",
+ "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"type\":\"ENRG\",\"device_state\":\"active\",\"output_state\":\"on\",\"volt_in\":13.07,\"volt_out\":13.07,\"off_reason\":\"NO_REASON\"}",
+ "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"type\":\"ENRG\",\"device_state\":\"off\",\"output_state\":\"off\",\"volt_in\":12.76,\"volt_out\":0.11,\"off_reason\":\"REMOTE_INPUT\"}",
+ "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"type\":\"ENRG\",\"device_state\":\"active\",\"output_state\":\"on\",\"volt_in\":12.64,\"volt_out\":12.64,\"off_reason\":\"NO_REASON\"}",
+ "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"type\":\"ENRG\",\"device_state\":\"off\",\"output_state\":\"off\",\"volt_in\":12.74,\"volt_out\":0.12,\"off_reason\":\"SWITCHED_OFF_REGISTER\"}",
+ "{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"type\":\"ENRG\",\"device_state\":\"off\",\"output_state\":\"off\",\"volt_in\":12.79,\"volt_out\":0.11,\"off_reason\":\"SWITCHED_OFF_REGISTER\"}",
};
const char* expected_name_uuid_mfgsvcdata[] = {
@@ -748,6 +755,13 @@ const char* test_mfgdata[][3] = {
{"H5055", "GVH5055", "d596c100648f221500ffff3f00221500ffff3f000000"},
{"H5055", "GVH5055", "d596c1006441221700ffff3f00221500ffff3f000000"},
{"H5055", "GVH5055", "d596c1006401201a00ffff3100221600ffff3f000000"},
+ {"Victron Smart Battery Protect ENC", "", "e1021000b0a309a82cdaf581a6631c3ddfccaa081fad4da6f4"},
+ {"Victron Smart Battery Protect", "", "e1021100b0a309ffffda0000000000000000050a0008000000"},
+ {"Victron Smart Battery Protect", "", "e1021100b0a309ffffdaf90100000000001b051b0500000000"},
+ {"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000fc040b0008000000"},
+ {"Victron Smart Battery Protect", "", "e1021100b0a309ffffdaf9010000000000f004f00400000000"},
+ {"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000fa040c0004000000"},
+ {"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000ff040b0004000000"},
};
TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
@@ -934,6 +948,13 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::H5055,
TheengsDecoder::BLE_ID_NUM::H5055,
TheengsDecoder::BLE_ID_NUM::H5055,
+ TheengsDecoder::BLE_ID_NUM::VICTSBP_ENCR,
+ TheengsDecoder::BLE_ID_NUM::VICTSBP,
+ TheengsDecoder::BLE_ID_NUM::VICTSBP,
+ TheengsDecoder::BLE_ID_NUM::VICTSBP,
+ TheengsDecoder::BLE_ID_NUM::VICTSBP,
+ TheengsDecoder::BLE_ID_NUM::VICTSBP,
+ TheengsDecoder::BLE_ID_NUM::VICTSBP,
};
// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]