How do I get the energy fed into AC In in kWh in Node-RED?

Hi

I’m running a MultiPlus 2 3000, which is connected to L1.

A Shelly 3EM is connected at the grid connection and integrated into Venus OS.

I make individual values available in my smart home system via Node-RED.

I can transfer the current power, but how do I access the generated kWh?
Can anyone point me in the right direction?

Update: Version 3.80 is currently installed

For now, I’ve put a Shelly 1PM in between. That’s probably the solution. It only has one drawback: the Shelly loses its readings when it’s disconnected from the mains.

I have a new Shelly Plug S3 (Node Red on the Cerbo)

Hi Fredd

thanks for your answer, also with the Shelly Plug S3 we have the problem that, like all shelly, it will loses its memory if the power fails or the device reboots.

And the system knows the values ​​from somewhere

I’ll answer my own question for once

It looks as though this setting produces the desired result

At least, the value looks plausible to me. I’ll monitor it for a while

This value is 0 after a reboot Cerbo.(on my Victron)

[
    {
        "id": "dc3124a9dd8f50ac",
        "type": "function",
        "z": "8c24bd44e2dbfb86",
        "name": "+MPPT_Netz_kWh",
        "func": "flow.set(\"Multi_Einsp_Rohwert\",msg.payload);\nmsg.payload=msg.payload+flow.get(\"MPPT_Netz_kWh\");\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 780,
        "wires": [
            [
                "d1d61e0e9982578c"
            ]
        ]
    },
    {
        "id": "9931112638ebda42",
        "type": "victron-input-vebus",
        "z": "8c24bd44e2dbfb86",
        "service": "com.victronenergy.vebus/290",
        "path": "/Energy/InverterToAcIn1",
        "serviceObj": {
            "service": "com.victronenergy.vebus/290",
            "name": "MultiPlus-II 48/3000/35-32",
            "communityTag": "vebus"
        },
        "pathObj": {
            "path": "/Energy/InverterToAcIn1",
            "type": "float",
            "name": "Energy Inverter to AcIn1 (kWh)"
        },
        "initial": "",
        "name": "Multi Einspeisung",
        "onlyChanges": false,
        "roundValues": "2",
        "outputs": 1,
        "conditionalMode": false,
        "outputTrue": "",
        "outputFalse": "",
        "debounce": "",
        "x": 140,
        "y": 780,
        "wires": [
            [
                "0e135e5256fdcf59",
                "dc3124a9dd8f50ac"
            ]
        ]
    },
    {
        "id": "d1d61e0e9982578c",
        "type": "change",
        "z": "8c24bd44e2dbfb86",
        "name": "Sol3_Netz_kWh",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "Solar3_Netz",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "Sol3_Netz_kWh",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 780,
        "wires": [
            [
                "99da1695bac7a4ef",
                "5fe38b95867a3213",
                "912c39268c90762b",
                "18f4e88a5f72d08d"
            ]
        ]
    },
    {
        "id": "dda43b9e94ce88ac",
        "type": "inject",
        "z": "8c24bd44e2dbfb86",
        "name": "MPPT_Netz_kWh_Offset",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "00 00 * * 1,3,5,0",
        "once": false,
        "onceDelay": "1",
        "topic": "MPPT_Gesamt",
        "payload": "Sol3_Netz_kWh",
        "payloadType": "flow",
        "x": 250,
        "y": 960,
        "wires": [
            [
                "f540fa638b94f781"
            ]
        ]
    },
    {
        "id": "bf886b91895b33ef",
        "type": "inject",
        "z": "8c24bd44e2dbfb86",
        "name": "Neustart",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "2",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 1000,
        "wires": [
            [
                "1dd4641534ece333"
            ]
        ]
    },
    {
        "id": "56247c3ebfa928b4",
        "type": "switch",
        "z": "8c24bd44e2dbfb86",
        "name": "Multi_Einsp_Rohwert<1",
        "property": "Multi_Einsp_Rohwert",
        "propertyType": "flow",
        "rules": [
            {
                "t": "lt",
                "v": "2",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 690,
        "y": 1000,
        "wires": [
            [
                "c7db9e14ecfb011f"
            ]
        ]
    },
    {
        "id": "da7b66a1b9ea804b",
        "type": "change",
        "z": "8c24bd44e2dbfb86",
        "name": "to Number",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$number(payload)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 1000,
        "wires": [
            [
                "56247c3ebfa928b4"
            ]
        ]
    },
    {
        "id": "1dd4641534ece333",
        "type": "file in",
        "z": "8c24bd44e2dbfb86",
        "name": "gesamt",
        "filename": "//data/home/nodered/.node-red/MPPT-kWh.txt",
        "filenameType": "str",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 300,
        "y": 1000,
        "wires": [
            [
                "da7b66a1b9ea804b"
            ]
        ]
    },
    {
        "id": "c7db9e14ecfb011f",
        "type": "change",
        "z": "8c24bd44e2dbfb86",
        "name": "MPPT_Netz_kWh",
        "rules": [
            {
                "t": "set",
                "p": "MPPT_Netz_kWh",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 910,
        "y": 1000,
        "wires": [
            []
        ]
    },
    {
        "id": "f540fa638b94f781",
        "type": "file",
        "z": "8c24bd44e2dbfb86",
        "name": "gesamt",
        "filename": "//data/home/nodered/.node-red/MPPT-kWh.txt",
        "filenameType": "str",
        "appendNewline": false,
        "createDir": false,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 440,
        "y": 960,
        "wires": [
            []
        ]
    },
    {
        "id": "170a0983bc30c783",
        "type": "global-config",
        "env": [],
        "modules": {
            "@victronenergy/node-red-contrib-victron": "1.6.64"
        }
    }
]

I use this flow to save the Multi’s meter reading regularly. It is read when the system restarts, so it isn’t lost. Don’t save it too often, otherwise it can wear out the SD card — if one is being used.

Brilliant flow
I have a question: can Node-RED simply write to the directory, or do I need to configure something?
Update:
The file is created; you just need to ensure initially that a value is entered, otherwise it shows “NaN” as the value