Skip to content

Commit 91e8822

Browse files
authored
Victron Smart BatteryProtect amendments (#632)
1 parent 68bbce0 commit 91e8822

File tree

4 files changed

+32
-51
lines changed

4 files changed

+32
-51
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Theengs Decoder library translates these data chains into human readable data le
1111

1212
It's also a simplified way of defining the thing properties and how to decode these.
1313

14-
Theengs Decoder supports the decoding of [more than 100 Bluetooth devices](https://decoder.theengs.io/devices/devices.html).
14+
Theengs Decoder supports the decoding of [more than 120 Bluetooth devices](https://decoder.theengs.io/devices/devices.html).
1515

1616
Theengs Decoder can be used on memory constraint environments like micro controllers (ESP32, ESP8266, Arduino), on a PC or on a Unix server.
1717
Unit testing assures that the modification done on the library doesn't affect previous capabilities.

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Theengs Decoder library translates these data chains into human readable data le
1616

1717
It's also a simplified way of defining the thing properties and how to decode these.
1818

19-
Theengs Decoder supports the decoding of [more than 100 Bluetooth devices](https://decoder.theengs.io/devices/devices.html).
19+
Theengs Decoder supports the decoding of [more than 120 Bluetooth devices](https://decoder.theengs.io/devices/devices.html).
2020

2121
Theengs Decoder can be used on memory constraint environments like micro controllers (ESP32, ESP8266, Arduino), on a PC or on a Unix server.
2222
Unit testing assures that the modification done on the library doesn't affect previous capabilities.

src/devices/VICTRON_DCDC_json.h

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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\"]}}}";
1+
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\":{\"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\",\"ff\",\"N/A\"]},\"output_state\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",22,2],\"lookup\":[\"00\",\"off\",\"01\",\"on\",\"ff\",\"N/A\"]},\"volt_in\":{\"condition\":[\"manufacturerdata\",34,\"!\",\"7fff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",34,4,true,true],\"post_proc\":[\"/\",100]},\"volt_out\":{\"condition\":[\"manufacturerdata\",38,\"!\",\"ffff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",38,4,true,false],\"post_proc\":[\"/\",100]},\"error_code\":{\"condition\":[\"manufacturerdata\",24,\"!\",\"ff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,2]},\"alarm_reason\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",26,4]},\"warning_reason\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",30,4]}}}";
22
/*R""""(
33
{
44
"brand":"Victron Energy",
@@ -8,7 +8,6 @@ const char* _VICTSBP_json = "{\"brand\":\"Victron Energy\",\"model\":\"Smart Bat
88
"condition":["manufacturerdata", "=", 50, "index", 0, "e10211", "&", "manufacturerdata", "index", 12, "09ffff"],
99
"properties":{
1010
"device_state":{
11-
"condition":["manufacturerdata", 20, "!", "ff"],
1211
"decoder":["string_from_hex_data", "manufacturerdata", 20, 2],
1312
"lookup":["00", "off",
1413
"01", "low power",
@@ -25,53 +24,39 @@ const char* _VICTSBP_json = "{\"brand\":\"Victron Energy\",\"model\":\"Smart Bat
2524
"f7", "recondition",
2625
"f8", "battery safe",
2726
"f9", "active",
28-
"fc", "external control"]
27+
"fc", "external control",
28+
"ff", "N/A"]
2929
},
3030
"output_state":{
31-
"condition":["manufacturerdata", 22, "!", "ff"],
3231
"decoder":["string_from_hex_data", "manufacturerdata", 22, 2],
3332
"lookup":["00", "off",
34-
"01", "on"]
35-
},
36-
"error_code":{
37-
"condition":["manufacturerdata", 24, "!", "ff", "&", "manufacturerdata", 24, "!", "00"],
38-
"decoder":["value_from_hex_data", "manufacturerdata", 24, 2]
39-
},
40-
"alarm_reason":{
41-
"condition":["manufacturerdata", 26, "!", "0000"],
42-
"decoder":["value_from_hex_data", "manufacturerdata", 26, 4]
43-
},
44-
"warning_reason":{
45-
"condition":["manufacturerdata", 30, "!", "0000"],
46-
"decoder":["value_from_hex_data", "manufacturerdata", 30, 4]
33+
"01", "on",
34+
"ff", "N/A"]
4735
},
4836
"volt_in":{
4937
"condition":["manufacturerdata", 34, "!", "7fff"],
5038
"decoder":["value_from_hex_data", "manufacturerdata", 34, 4, true, true],
5139
"post_proc":["/", 100]
5240
},
5341
"volt_out":{
54-
"condition":["manufacturerdata", 38, "!", "7fff"],
42+
"condition":["manufacturerdata", 38, "!", "ffff"],
5543
"decoder":["value_from_hex_data", "manufacturerdata", 38, 4, true, false],
5644
"post_proc":["/", 100]
5745
},
58-
"off_reason":{
59-
"decoder":["string_from_hex_data", "manufacturerdata", 42, 8],
60-
"lookup":["00000000", "NO_REASON",
61-
"01000000", "NO_INPUT_POWER",
62-
"02000000", "SWITCHED_OFF_SWITCH",
63-
"04000000", "SWITCHED_OFF_REGISTER",
64-
"08000000", "REMOTE_INPUT",
65-
"10000000", "PROTECTION_ACTIVE",
66-
"20000000", "PAY_AS_YOU_GO_OUT_OF_CREDIT",
67-
"40000000", "BMS",
68-
"80000000", "ENGINE_SHUTDOWN",
69-
"00010000", "ANALYSING_INPUT_VOLTAGE"]
46+
"error_code":{
47+
"condition":["manufacturerdata", 24, "!", "ff"],
48+
"decoder":["value_from_hex_data", "manufacturerdata", 24, 2]
49+
},
50+
"alarm_reason":{
51+
"decoder":["value_from_hex_data", "manufacturerdata", 26, 4]
52+
},
53+
"warning_reason":{
54+
"decoder":["value_from_hex_data", "manufacturerdata", 30, 4]
7055
}
7156
}
7257
})"""";*/
7358

74-
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\"}}}";
59+
const char* _VICTSBP_json_props = "{\"properties\":{\"device_state\":{\"unit\":\"string\",\"name\":\"device state\"},\"output_state\":{\"unit\":\"string\",\"name\":\"output state\"},\"volt_in\":{\"unit\":\"V\",\"name\":\"voltage\"},\"volt_out\":{\"unit\":\"V\",\"name\":\"voltage\"},\"error_code\":{\"unit\":\"int\",\"name\":\"error code\"},\"alarm_reason\":{\"unit\":\"int\",\"name\":\"alarm reason\"},\"warning_reason\":{\"unit\":\"int\",\"name\":\"warning reason\"}}}";
7560
/*R""""(
7661
{
7762
"properties":{
@@ -83,6 +68,14 @@ const char* _VICTSBP_json_props = "{\"properties\":{\"device_state\":{\"unit\":\
8368
"unit":"string",
8469
"name":"output state"
8570
},
71+
"volt_in": {
72+
"unit": "V",
73+
"name": "voltage"
74+
},
75+
"volt_out": {
76+
"unit": "V",
77+
"name": "voltage"
78+
},
8679
"error_code":{
8780
"unit":"int",
8881
"name":"error code"
@@ -94,18 +87,6 @@ const char* _VICTSBP_json_props = "{\"properties\":{\"device_state\":{\"unit\":\
9487
"warning_reason":{
9588
"unit":"int",
9689
"name":"warning reason"
97-
},
98-
"volt_in": {
99-
"unit": "V",
100-
"name": "voltage"
101-
},
102-
"volt_out": {
103-
"unit": "V",
104-
"name": "voltage"
105-
},
106-
"off_reason":{
107-
"unit":"string",
108-
"name":"off reason"
10990
}
11091
}
11192
})"""";*/

tests/BLE/test_ble.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ const char* expected_mfg[] = {
204204
"{\"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}",
205205
"{\"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}",
206206
"{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect encrypted\",\"model_id\":\"VICTSBP_ENCR\",\"type\":\"ENRG\",\"encr\":3,\"cipher\":\"f581a6631c3ddfccaa081fad4da6f4\",\"ctr\":\"a82c\",\"mic\":\"da\"}",
207-
"{\"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\"}",
208-
"{\"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\"}",
209-
"{\"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\"}",
210-
"{\"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\"}",
211-
"{\"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\"}",
212-
"{\"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\"}",
207+
"{\"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,\"error_code\":0,\"alarm_reason\":0,\"warning_reason\":0}",
208+
"{\"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,\"error_code\":0,\"alarm_reason\":0,\"warning_reason\":0}",
209+
"{\"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,\"error_code\":0,\"alarm_reason\":0,\"warning_reason\":0}",
210+
"{\"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,\"error_code\":0,\"alarm_reason\":0,\"warning_reason\":0}",
211+
"{\"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,\"error_code\":0,\"alarm_reason\":0,\"warning_reason\":0}",
212+
"{\"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,\"error_code\":0,\"alarm_reason\":0,\"warning_reason\":0}",
213213
};
214214

215215
const char* expected_name_uuid_mfgsvcdata[] = {

0 commit comments

Comments
 (0)