Flow to create an advanced widget for cell voltage difference

A simple flow that creates a virtual battery and calculates the cell voltage difference in mV and percentage deviation, inserting it as the virtual battery voltage.
If you then create a widget for the virtual battery voltage you will have a nice chart showing the cell difference over time and a summary on the VRM dashboard (unfortunately I can’t change the unit in VRM).
It does use the global variables for cell min/mx so you need to drop a victron BMS node for each of those anywhere in node red.

[
    {
        "id": "e454b672adeedd27",
        "type": "victron-virtual",
        "z": "20fec985ee013124",
        "name": "Cell Differnce mV",
        "outputs": 1,
        "device": "battery",
        "default_values": false,
        "acload_nrofphases": 1,
        "enable_s2support": false,
        "battery_capacity": "400",
        "include_battery_temperature": false,
        "battery_voltage_preset": "custom",
        "battery_voltage_custom": "20",
        "generator_type": "ac",
        "generator_nrofphases": 1,
        "include_engine_hours": false,
        "include_starter_voltage": false,
        "include_history_energy": false,
        "grid_nrofphases": 1,
        "include_motor_temp": false,
        "include_controller_temp": false,
        "include_coolant_temp": false,
        "include_motor_rpm": true,
        "include_motor_direction": true,
        "position": 0,
        "pvinverter_nrofphases": 1,
        "switch_1_type": 1,
        "switch_1_min": 0,
        "switch_1_max": "",
        "switch_1_initial": 0,
        "switch_1_label": "",
        "switch_1_unit": "",
        "switch_1_step": 1,
        "switch_1_customname": "",
        "switch_1_group": "",
        "switch_1_include_measurement": false,
        "switch_1_rgb_color_wheel": false,
        "switch_1_cct_wheel": false,
        "switch_1_rgb_white_dimmer": false,
        "fluid_type": 0,
        "include_tank_battery": false,
        "include_tank_temperature": false,
        "tank_battery_voltage": 3.3,
        "tank_capacity": 0.2,
        "temperature_type": 2,
        "include_humidity": false,
        "include_pressure": false,
        "include_temp_battery": false,
        "temp_battery_voltage": 3.3,
        "start_disconnected": false,
        "x": 190,
        "y": 980,
        "wires": [
            []
        ]
    },
    {
        "id": "b0f3ec50392a32ec",
        "type": "victron-output-custom",
        "z": "20fec985ee013124",
        "service": "com.victronenergy.battery/100",
        "path": "/Dc/0/Voltage",
        "serviceObj": {
            "service": "com.victronenergy.battery/100",
            "name": "Debug battery (100)"
        },
        "pathObj": {
            "path": "/Dc/0/Voltage",
            "name": "/Dc/0/Voltage",
            "type": "number",
            "value": 48
        },
        "name": "Cell Delta",
        "onlyChanges": false,
        "roundValues": "no",
        "rateLimit": 0,
        "conditionalMode": false,
        "condition1Operator": ">",
        "condition2Enabled": false,
        "condition2Service": "",
        "condition2Path": "",
        "condition2Operator": ">",
        "logicOperator": "AND",
        "outputTrue": "true",
        "outputFalse": "false",
        "outputOnChange": false,
        "debounce": 2000,
        "x": 580,
        "y": 980,
        "wires": []
    },
    {
        "id": "fcf4b01f34f27893",
        "type": "function",
        "z": "20fec985ee013124",
        "name": "Calc cell delta",
        "func": "let max = global.get(\"victronenergy.battery._512.System.MaxCellVoltage\");\nlet min = global.get(\"victronenergy.battery._512.System.MinCellVoltage\");\nlet delta = Math.round((max - min)*100);\nflow.set(\"celldelta\",delta);\nmsg.payload = delta;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 980,
        "wires": [
            [
                "b0f3ec50392a32ec"
            ]
        ]
    },
    {
        "id": "a8dad2026f4245b2",
        "type": "inject",
        "z": "20fec985ee013124",
        "name": "trigger",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "5",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 340,
        "y": 900,
        "wires": [
            [
                "fcf4b01f34f27893",
                "73b40d79d6d7ccac"
            ]
        ]
    },
    {
        "id": "b7eede020a033404",
        "type": "victron-output-custom",
        "z": "20fec985ee013124",
        "service": "com.victronenergy.battery/100",
        "path": "/Soc",
        "serviceObj": {
            "service": "com.victronenergy.battery/100",
            "name": "Debug battery (100)"
        },
        "pathObj": {
            "path": "/Soc",
            "name": "/Soc",
            "type": "number",
            "value": 80
        },
        "name": "SOC",
        "onlyChanges": false,
        "roundValues": "no",
        "rateLimit": 0,
        "conditionalMode": false,
        "condition1Operator": ">",
        "condition2Enabled": false,
        "condition2Service": "",
        "condition2Path": "",
        "condition2Operator": ">",
        "logicOperator": "AND",
        "outputTrue": "true",
        "outputFalse": "false",
        "outputOnChange": false,
        "debounce": 2000,
        "x": 590,
        "y": 1060,
        "wires": []
    },
    {
        "id": "73b40d79d6d7ccac",
        "type": "function",
        "z": "20fec985ee013124",
        "name": "SOC",
        "func": "let delta = flow.get(\"celldelta\");\nlet avgv = global.get(\"victronenergy.battery._512.Dc._0.Voltage\")/16*1000;\nmsg.payload = Number(((delta / avgv) * 100).toFixed(3));\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 310,
        "y": 1060,
        "wires": [
            [
                "b7eede020a033404"
            ]
        ]
    },
    {
        "id": "bc9b19d300371c34",
        "type": "victron-input-battery",
        "z": "20fec985ee013124",
        "service": "com.victronenergy.battery/512",
        "path": "/Dc/0/Voltage",
        "serviceObj": {
            "service": "com.victronenergy.battery/512",
            "name": "Fleadung Wonk",
            "communityTag": "battery"
        },
        "pathObj": {
            "path": "/Dc/0/Voltage",
            "type": "float",
            "name": "Battery voltage (V)"
        },
        "name": "Battery Voltage",
        "onlyChanges": false,
        "roundValues": "no",
        "rateLimit": 0,
        "conditionalMode": false,
        "outputTrue": "true",
        "outputFalse": "false",
        "debounce": "2000",
        "x": 180,
        "y": 1100,
        "wires": [
            []
        ]
    },
    {
        "id": "4fa151dc23989d7b",
        "type": "global-config",
        "env": [],
        "modules": {
            "@victronenergy/node-red-contrib-victron": "1.7.3"
        }
    }
]

2 Likes