VRM recieving zero values from virtual device type energy meter

My VRM page is recieving zero values from my virtual device, at start-up or nede-red deploy.
I tried to catch all zero values in my function and in the debug window i do not see these zeros.
In moste cases these zeros are harmless, but especially for calculating the correct consumption it is quite anoying. Becaus this leads to unrealistic spikes in the VRM view.

My Flow:

[
    {
        "id": "856ecdc694e20334",
        "type": "victron-virtual",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "Ladestation",
        "outputs": 1,
        "device": "energymeter",
        "default_values": false,
        "acload_nrofphases": 1,
        "enable_s2support": false,
        "battery_capacity": 25,
        "include_battery_temperature": false,
        "battery_voltage_preset": "24",
        "battery_voltage_custom": 24,
        "generator_type": "ac",
        "generator_nrofphases": 1,
        "include_engine_hours": false,
        "include_starter_voltage": false,
        "include_history_energy": false,
        "grid_nrofphases": 1,
        "energymeter_nrofphases": 1,
        "energymeter_role": "evcharger",
        "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,
        "ev_vin": "",
        "ev_battery_capacity": "",
        "temperature_type": 2,
        "include_humidity": false,
        "include_pressure": false,
        "include_temp_battery": false,
        "temp_battery_voltage": 3.3,
        "start_disconnected": true,
        "x": 550,
        "y": 80,
        "wires": [
            [
                "c627e81c7b83067d"
            ]
        ]
    },
    {
        "id": "722014b859612718",
        "type": "function",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "Parse Modbus Massage",
        "func": "//initialisierung Speichervariablen\n// var time = new Date();\n// var thisTime = time.getTime();\n// context.LastTime = context.LastTime || thisTime;\n// context.Power = context.Power || 0;\n// context.Voltage = context.Voltage || 230.1;\n// context.LadeStatus = context.LadeStatus || 0;\n// context.vCarger1TotEnergy = context.vCarger1TotEnergy || 0;\n// context.vCarger1SessionStartEnergy = context.vCarger1SessionStartEnergy || 0;\n// context.vCarger1SessionStartTime = context.vCarger1SessionStartTime || 0;\n\nvar ChargingPpower = 0;\nvar data = msg.payload;\nif ((data[53] * 65536) + data[52] ==0) {return;} \n\nif (msg.payload.length >=70){\n    AcL1Power = ((data[19] * 65536) + data[18])/10;\n    AcL2Power = ((data[21] * 65536) + data[20])/10;\n    AcL3Power = ((data[32] * 65536) + data[22])/10;\n    AcL1PowerFactor = (data[46] >= 32768) ? (data[46]-65536)/1000 : data[46]/1000;\n    AcL2PowerFactor = (data[47] >= 32768) ? (data[47]-65536)/1000 : data[47]/1000;\n    AcL3PowerFactor = (data[48] >= 32768) ? (data[48]-65536)/1000 : data[48]/1000;\n    AcPowerFactor = (data[49] >= 32768) ? (data[49]-65536)/1000 : data[49]/1000;\n    // AcFrequency = (data[51] >= 32768) ? (data[51]-65536)/1000 : data[51]/10;\n\n    // power = AcL1Power-((AcL2Power+AcL3Power)/2);\n    if (msg.modbusRequest.name == 'Modbus EM-Whng1'){\n        if (AcL1Power > 3400 && context.Power ==0) {\n            context.Power = 3600;\n            context.vCarger1SessionStartTime = thisTime;\n            context.vCarger1SessionStartEnergy = ((data[65] * 65536) + data[64])/10;\n        }else if (AcL1Power < 2400) {context.Power = 0;\n        }else if (context.Power == 3600 && (2300 < AcL1Power && AcL1Power < 3200 )) {context.Power = 2600;}\n        ChargingPpower = context.Power < AcL1Power ? context.Power : AcL1Power;\n        // if (thisTime > context.LastTime) {\n        //     //var TotEnergy = context.vCarger1TotEnergy ;\n        //     context.vCarger1TotEnergy += (ChargingPpower * (thisTime-context.LastTime)/1000/60/60/1000);\n        //     context.vCarger1SessionEnergy += (ChargingPpower * (thisTime-context.LastTime)/1000/60/60/1000);\n        //     context.LastTime = thisTime;\n        // }\n        var msgCharger = { payload: msg.payload };\n        msgCharger.topic = \"Ladestation\";\n        if (!context.connectedCharger ) {\n            msgCharger.connected = true;\n            context.connectedCharger = true;\n        }\n        msgCharger.payload = {\"/Ac/Power\": ChargingPpower, \n                    \"/Ac/L1/Power\": ChargingPpower,\n                    \"/Ac/L1/Voltage\": ((data[1] * 65536) + data[0])/10,\n                    // \"/Ac/L1/Current\": context.Power/((data[1] * 65536) + data[0])/10, \n                    // \"/Ac/Energy/Forward\": context.vCarger1TotEnergy,\n                    // \"/Ac/Energy/Reverse\": 0,\n                    // \"/Ac/L1/Energy/Forward\": context.vCarger1TotEnergy,\n                    // \"/Ac/L1/Energy/Reverse\": 0,\n                    \"/Ac/L1/PowerFactor\": AcL1PowerFactor,\n                    // \"/Session/Time\": (thisTime - context.vCarger1SessionStartTime)/1000, //<-- Session charging time (seconds)\n                    // \"/Session/Energy\": ((data[65] * 65536) + data[64])/10 - context.vCarger1SessionStartEnergy, //<-- Session charging energy (kWh)\n                    // \"/Session/Cost\": (((data[65] * 65536) + data[64])/10 - context.vCarger1SessionStartEnergy) * 0.4, //<-- Session cost (no currency)\"\n                    \"/DeviceType\": 71,\n                    \"/Position\": 1, //       <-- 0=AC Output, 1=AC Input\n                    // \"/PositionIsAdjustable\": 1,\n                    \"/IsGenericEnergyMeter\": 1,\n                    \"/ErrorCode\": 0};\n    }\n\n    msg.payload = {\"/Ac/Power\": ((data[41] * 65536) + data[40])/10 - ChargingPpower, \n                \"/Ac/L1/Power\": ((data[19] * 65536) + data[18])/10 - ChargingPpower,\n                \"/Ac/L2/Power\": ((data[21] * 65536) + data[20])/10,\n                \"/Ac/L3/Power\": ((data[23] * 65536) + data[22])/10,\n                \"/Ac/L1/Voltage\": ((data[1] * 65536) + data[0])/10,\n                \"/Ac/L2/Voltage\": ((data[3] * 65536) + data[2])/10,\n                \"/Ac/L3/Voltage\": ((data[5] * 65536) + data[4])/10,\n                \"/Ac/L1/Current\": ((data[13] * 65536) + data[12])/1000, \n                \"/Ac/L2/Current\": ((data[15] * 65536) + data[14])/1000, \n                \"/Ac/L3/Current\": ((data[17] * 65536) + data[16])/1000, \n                \"/Ac/Energy/Forward\": ((data[53] * 65536) + data[52])/10,\n                // \"/Ac/Energy/Reverse\": ((data[79] * 65536) + data[78])/10,\n                \"/Ac/L1/Energy/Forward\": ((data[65] * 65536) + data[64])/10,\n                \"/Ac/L2/Energy/Forward\": ((data[67] * 65536) + data[66])/10,\n                \"/Ac/L3/Energy/Forward\": ((data[69] * 65536) + data[68])/10,\n                \"/Ac/L1/PowerFactor\": AcL1PowerFactor,\n                \"/Ac/L2/PowerFactor\": AcL3PowerFactor,\n                \"/Ac/L3/PowerFactor\": AcL3PowerFactor,\n                \"/Ac/PowerFactor\": AcPowerFactor,\n                // \"/Ac/Frequency\": AcFrequency,\n                \"/DeviceType\": 71,\n                \"/Position\": 1, //       <-- 0=AC Output, 1=AC Input\n                \"/IsGenericEnergyMeter\": 1,\n                // \"/ProductName\":,\n                // \"/CustomName\":,\n                // \"/Mgmt/Connection\":,\n                // \"/Mgmt/ProcessName\":,\n                // \"/Mgmt/ProcessVersion\":,\n                \"/Connected\": true,\n                // \"/DeviceInstance\":,\n                // \"/ProductId\":,\n                // \"/Serial\":,\n                // \"/HardwareVersion\":,\n                // \"/FirmwareVersion\":,\n                \"/ErrorCode\": 0};\n\n\n\n    if (msg.modbusRequest.name == 'Modbus EM-Whng1') {\n        msg.topic = \"EM Whng1\";\n        if (!context.connectedWhng1 ) {\n            msg.connected = true;\n            context.connectedWhng1 = true;\n        }\n                    \n                   \n                    \n        return [msgCharger, msg, null];\n    }else if (msg.modbusRequest.name == 'Modbus EM-Whng2') {\n\n        msg.topic = \"EM Whng2\";\n        if (!context.connectedWhng2 ) {\n            msg.connected = true;\n            context.connectedWhng2 = true;\n        }\n        return [null, null, msg];\n        \n    }\n}\n\nreturn;\n",
        "outputs": 3,
        "timeout": 0,
        "noerr": 0,
        "initialize": "// Der Code hier wird ausgeführt,\n// wenn der Node gestartet wird\nvar time = new Date();\nvar thisTime = time.getTime();\ncontext.LastTime = context.LastTime || thisTime;\ncontext.Power = context.Power || 0;\ncontext.Voltage = context.Voltage || 230.1;\ncontext.LadeStatus = context.LadeStatus || 0;\ncontext.vCarger1TotEnergy = context.vCarger1TotEnergy || 0;\ncontext.vCarger1SessionStartEnergy = context.vCarger1SessionStartEnergy || 0;\ncontext.vCarger1SessionStartTime = context.vCarger1SessionStartTime || 0;\ncontext.connectedCharger = false;\ncontext.connectedWhng1 = false;\ncontext.connectedWhng2 = false;\n",
        "finalize": "",
        "libs": [],
        "x": 250,
        "y": 140,
        "wires": [
            [
                "856ecdc694e20334"
            ],
            [
                "5247249cab547a08"
            ],
            [
                "6c45e586532b1de0"
            ]
        ]
    },
    {
        "id": "914d2a9baac0098d",
        "type": "inject",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "1s",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "connected",
                "v": "true",
                "vt": "bool"
            },
            {
                "p": "payload"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "Inject",
        "payload": "poll",
        "payloadType": "str",
        "x": 110,
        "y": 60,
        "wires": [
            [
                "bc5cc6a7a51164b9"
            ]
        ]
    },
    {
        "id": "c627e81c7b83067d",
        "type": "debug",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "debug 5",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload[\"/Ac/PowerFactor\"]",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 760,
        "y": 100,
        "wires": []
    },
    {
        "id": "bc5cc6a7a51164b9",
        "type": "modbus-flex-sequencer",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "WS-Modbus GW",
        "sequences": [
            {
                "name": "Modbus EM-Whng1",
                "unitid": "2",
                "fc": "FC3",
                "address": "0",
                "quantity": "70"
            },
            {
                "name": "Modbus EM-Whng2",
                "unitid": "1",
                "fc": "FC3",
                "address": "0",
                "quantity": "70"
            }
        ],
        "server": "f711060803f2f104",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "logIOActivities": false,
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 270,
        "y": 60,
        "wires": [
            [
                "722014b859612718"
            ],
            []
        ]
    },
    {
        "id": "5247249cab547a08",
        "type": "victron-virtual",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "EM-Whng1",
        "outputs": 1,
        "device": "energymeter",
        "default_values": false,
        "acload_nrofphases": 1,
        "enable_s2support": false,
        "battery_capacity": 25,
        "include_battery_temperature": false,
        "battery_voltage_preset": "24",
        "battery_voltage_custom": 24,
        "generator_type": "ac",
        "generator_nrofphases": 1,
        "include_engine_hours": false,
        "include_starter_voltage": false,
        "include_history_energy": false,
        "grid_nrofphases": 1,
        "energymeter_nrofphases": "3",
        "energymeter_role": "acload",
        "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,
        "ev_vin": "",
        "ev_battery_capacity": "",
        "temperature_type": 2,
        "include_humidity": false,
        "include_pressure": false,
        "include_temp_battery": false,
        "temp_battery_voltage": 3.3,
        "start_disconnected": true,
        "x": 550,
        "y": 140,
        "wires": [
            [
                "c627e81c7b83067d"
            ]
        ]
    },
    {
        "id": "6c45e586532b1de0",
        "type": "victron-virtual",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "EM-Whng2",
        "outputs": 1,
        "device": "energymeter",
        "default_values": false,
        "acload_nrofphases": 1,
        "enable_s2support": false,
        "battery_capacity": 25,
        "include_battery_temperature": false,
        "battery_voltage_preset": "24",
        "battery_voltage_custom": 24,
        "generator_type": "ac",
        "generator_nrofphases": 1,
        "include_engine_hours": false,
        "include_starter_voltage": false,
        "include_history_energy": false,
        "grid_nrofphases": 1,
        "energymeter_nrofphases": "3",
        "energymeter_role": "acload",
        "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,
        "ev_vin": "",
        "ev_battery_capacity": "",
        "temperature_type": 2,
        "include_humidity": false,
        "include_pressure": false,
        "include_temp_battery": false,
        "temp_battery_voltage": 3.3,
        "start_disconnected": true,
        "x": 550,
        "y": 200,
        "wires": [
            [
                "c627e81c7b83067d"
            ]
        ]
    },
    {
        "id": "8bdcc27f8e1bdfc4",
        "type": "debug",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "debug 6",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 280,
        "wires": []
    },
    {
        "id": "f475245b3fe836d2",
        "type": "modbus-flex-sequencer",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "WS-Modbus GW",
        "sequences": [
            {
                "name": "Modbus EM-Whng1",
                "unitid": "2",
                "fc": "FC3",
                "address": "20480",
                "quantity": "7"
            },
            {
                "name": "Modbus EM-Whng2",
                "unitid": "1",
                "fc": "FC3",
                "address": "20480",
                "quantity": "7"
            }
        ],
        "server": "f711060803f2f104",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "logIOActivities": false,
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 270,
        "y": 200,
        "wires": [
            [],
            [
                "98244d1fcc4fa589"
            ]
        ]
    },
    {
        "id": "6be3271885881e0a",
        "type": "inject",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "1x",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "connected",
                "v": "true",
                "vt": "bool"
            },
            {
                "p": "payload"
            }
        ],
        "repeat": "60",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "Inject",
        "payload": "poll",
        "payloadType": "str",
        "x": 110,
        "y": 200,
        "wires": [
            [
                "f475245b3fe836d2"
            ]
        ]
    },
    {
        "id": "98244d1fcc4fa589",
        "type": "function",
        "z": "bc27b6ec94076234",
        "g": "22e55e0c6aec1e5f",
        "name": "Parse Serial",
        "func": "\n\nif (msg.modbusRequest.name == 'Modbus EM-Whng1') {\n    msg.payload = {\"/Serial\": String(msg.payload.buffer).replace('\\0', '')};\n    return [msg, null];\n}else if (msg.modbusRequest.name == 'Modbus EM-Whng2') {\n    msg.payload = {\"/Serial\": String(msg.payload.buffer).replace('\\0', '')};\n\n    return [null, msg];\n}\nreturn;\n",
        "outputs": 2,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 290,
        "y": 280,
        "wires": [
            [
                "8bdcc27f8e1bdfc4",
                "5247249cab547a08"
            ],
            [
                "8bdcc27f8e1bdfc4",
                "6c45e586532b1de0"
            ]
        ]
    },
    {
        "id": "f711060803f2f104",
        "type": "modbus-client",
        "name": "WS-Gateway 2",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": true,
        "failureLogEnabled": true,
        "tcpHost": "192.168.13.106",
        "tcpPort": 502,
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": 9600,
        "serialDatabits": 8,
        "serialStopbits": 1,
        "serialParity": "none",
        "serialConnectionDelay": 100,
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": 2,
        "commandDelay": 1,
        "clientTimeout": 1000,
        "reconnectOnTimeout": true,
        "reconnectTimeout": 2000,
        "parallelUnitIdsAllowed": true,
        "showErrors": false,
        "showWarnings": true,
        "showLogs": true
    },
    {
        "id": "d819801c7cd9cd35",
        "type": "global-config",
        "env": [],
        "modules": {
            "@victronenergy/node-red-contrib-victron": "1.7.8",
            "node-red-contrib-modbus": "5.45.2"
        }
    }
]

Does any one has an idea what am i missing?
Or is this a bug that other have seen to.

Without code from those functions, hard to say what goes wrong :frowning:

Looks like you might be using Shelly EM - have you tried to simply and install Shelly palette in node-red?

Here the function code.
”Parse Modbus Massage”:

//initialization moved to "Start"
// var time = new Date();
// var thisTime = time.getTime();
// context.LastTime = context.LastTime || thisTime;
// context.Power = context.Power || 0;
// context.Voltage = context.Voltage || 230.1;
// context.LadeStatus = context.LadeStatus || 0;
// context.vCarger1TotEnergy = context.vCarger1TotEnergy || 0;
// context.vCarger1SessionStartEnergy = context.vCarger1SessionStartEnergy || 0;
// context.vCarger1SessionStartTime = context.vCarger1SessionStartTime || 0;

var ChargingPpower = 0;
var data = msg.payload;
if ((data[53] * 65536) + data[52] ==0) {return;} 

if (msg.payload.length >=70){
    AcL1Power = ((data[19] * 65536) + data[18])/10;
    AcL2Power = ((data[21] * 65536) + data[20])/10;
    AcL3Power = ((data[32] * 65536) + data[22])/10;
    AcL1PowerFactor = (data[46] >= 32768) ? (data[46]-65536)/1000 : data[46]/1000;
    AcL2PowerFactor = (data[47] >= 32768) ? (data[47]-65536)/1000 : data[47]/1000;
    AcL3PowerFactor = (data[48] >= 32768) ? (data[48]-65536)/1000 : data[48]/1000;
    AcPowerFactor = (data[49] >= 32768) ? (data[49]-65536)/1000 : data[49]/1000;
    // AcFrequency = (data[51] >= 32768) ? (data[51]-65536)/1000 : data[51]/10;

    // power = AcL1Power-((AcL2Power+AcL3Power)/2);
    if (msg.modbusRequest.name == 'Modbus EM-Whng1'){
        if (AcL1Power > 3400 && context.Power ==0) {
            context.Power = 3600;
            context.vCarger1SessionStartTime = thisTime;
            context.vCarger1SessionStartEnergy = ((data[65] * 65536) + data[64])/10;
        }else if (AcL1Power < 2400) {context.Power = 0;
        }else if (context.Power == 3600 && (2300 < AcL1Power && AcL1Power < 3200 )) {context.Power = 2600;}
        ChargingPpower = context.Power < AcL1Power ? context.Power : AcL1Power;
        // if (thisTime > context.LastTime) {
        //     //var TotEnergy = context.vCarger1TotEnergy ;
        //     context.vCarger1TotEnergy += (ChargingPpower * (thisTime-context.LastTime)/1000/60/60/1000);
        //     context.vCarger1SessionEnergy += (ChargingPpower * (thisTime-context.LastTime)/1000/60/60/1000);
        //     context.LastTime = thisTime;
        // }
        var msgCharger = { payload: msg.payload };
        msgCharger.topic = "Ladestation";
        if (!context.connectedCharger ) {
            msgCharger.connected = true;
            context.connectedCharger = true;
        }
        msgCharger.payload = {"/Ac/Power": ChargingPpower, 
                    "/Ac/L1/Power": ChargingPpower,
                    "/Ac/L1/Voltage": ((data[1] * 65536) + data[0])/10,
                    // "/Ac/L1/Current": context.Power/((data[1] * 65536) + data[0])/10, 
                    // "/Ac/Energy/Forward": context.vCarger1TotEnergy,
                    // "/Ac/Energy/Reverse": 0,
                    // "/Ac/L1/Energy/Forward": context.vCarger1TotEnergy,
                    // "/Ac/L1/Energy/Reverse": 0,
                    "/Ac/L1/PowerFactor": AcL1PowerFactor,
                    // "/Session/Time": (thisTime - context.vCarger1SessionStartTime)/1000, //<-- Session charging time (seconds)
                    // "/Session/Energy": ((data[65] * 65536) + data[64])/10 - context.vCarger1SessionStartEnergy, //<-- Session charging energy (kWh)
                    // "/Session/Cost": (((data[65] * 65536) + data[64])/10 - context.vCarger1SessionStartEnergy) * 0.4, //<-- Session cost (no currency)"
                    "/DeviceType": 71,
                    "/Position": 1, //       <-- 0=AC Output, 1=AC Input
                    // "/PositionIsAdjustable": 1,
                    "/IsGenericEnergyMeter": 1,
                    "/ErrorCode": 0};
    }

    msg.payload = {"/Ac/Power": ((data[41] * 65536) + data[40])/10 - ChargingPpower, 
                "/Ac/L1/Power": ((data[19] * 65536) + data[18])/10 - ChargingPpower,
                "/Ac/L2/Power": ((data[21] * 65536) + data[20])/10,
                "/Ac/L3/Power": ((data[23] * 65536) + data[22])/10,
                "/Ac/L1/Voltage": ((data[1] * 65536) + data[0])/10,
                "/Ac/L2/Voltage": ((data[3] * 65536) + data[2])/10,
                "/Ac/L3/Voltage": ((data[5] * 65536) + data[4])/10,
                "/Ac/L1/Current": ((data[13] * 65536) + data[12])/1000, 
                "/Ac/L2/Current": ((data[15] * 65536) + data[14])/1000, 
                "/Ac/L3/Current": ((data[17] * 65536) + data[16])/1000, 
                "/Ac/Energy/Forward": ((data[53] * 65536) + data[52])/10,
                // "/Ac/Energy/Reverse": ((data[79] * 65536) + data[78])/10,
                "/Ac/L1/Energy/Forward": ((data[65] * 65536) + data[64])/10,
                "/Ac/L2/Energy/Forward": ((data[67] * 65536) + data[66])/10,
                "/Ac/L3/Energy/Forward": ((data[69] * 65536) + data[68])/10,
                "/Ac/L1/PowerFactor": AcL1PowerFactor,
                "/Ac/L2/PowerFactor": AcL3PowerFactor,
                "/Ac/L3/PowerFactor": AcL3PowerFactor,
                "/Ac/PowerFactor": AcPowerFactor,
                // "/Ac/Frequency": AcFrequency,
                "/DeviceType": 71,
                "/Position": 1, //       <-- 0=AC Output, 1=AC Input
                "/IsGenericEnergyMeter": 1,
                // "/ProductName":,
                // "/CustomName":,
                // "/Mgmt/Connection":,
                // "/Mgmt/ProcessName":,
                // "/Mgmt/ProcessVersion":,
                "/Connected": true,
                // "/DeviceInstance":,
                // "/ProductId":,
                // "/Serial":,
                // "/HardwareVersion":,
                // "/FirmwareVersion":,
                "/ErrorCode": 0};



    if (msg.modbusRequest.name == 'Modbus EM-Whng1') {
        msg.topic = "EM Whng1";
        if (!context.connectedWhng1 ) {
            msg.connected = true;
            context.connectedWhng1 = true;
        }
                    
                   
                    
        return [msgCharger, msg, null];
    }else if (msg.modbusRequest.name == 'Modbus EM-Whng2') {

        msg.topic = "EM Whng2";
        if (!context.connectedWhng2 ) {
            msg.connected = true;
            context.connectedWhng2 = true;
        }
        return [null, null, msg];
        
    }
}

return;


“Parse Serial”:



if (msg.modbusRequest.name == 'Modbus EM-Whng1') {
    msg.payload = {"/Serial": String(msg.payload.buffer).replace('\0', '')};
    return [msg, null];
}else if (msg.modbusRequest.name == 'Modbus EM-Whng2') {
    msg.payload = {"/Serial": String(msg.payload.buffer).replace('\0', '')};

    return [null, msg];
}
return;

You can have also a look in the Flow I attached before.

Hello, is AcL3 power register right? first you use 32 and then 23

Thanks, that’s an typo!
But has no effect on the Energy.
These zeros/spikes only accrue when Node-Red reloads or deploy. If all is running normally the virtual device is running fine. It seems for me that there is a handling issue on DBus or VRM that turns a “unavailable”/”null” into 0.

Try to declare this in let/var.

What debug show in first send to vrm?

I’ve found the issue! @Victron
It’s because I’m sending the “connected” message along with the “payload” objects.

msg.payload = {"/Ac/Power": Bytes2Int32(data[40],data[41])/10, 
               "/Ac/L1/Power": Bytes2Int32(data[18],data[19])/10,
               "/Ac/L2/Power": Bytes2Int32(data[20],data[21])/10,
               ...
               };
msg.connected = true;

If I make sure that the payload objects overwrite the default values first and then send the “connected” message, no zeros appear.
If payload objects sent together with the “connected” message, only the energy meter is connected (with default values) without the payload objects being applied.

I assume that if I set the “Initialize with defaults” box, to “No”, I can handle this scenario—ensuring that only valid values are written and no unchecked zero values are written.

My solution is to delay the “connected” message slightly, so that valid values have already been sent to the device.