Node Red en Shelly TIP (from Andy)

A very useful Node-RED tip from Andy at Off-grid Garage for assigning other functions to Shelly devices in Venus OS.
Including Downloads

Here is my solution for installing a Shelly PM1 Gen 3 as a virtual PV inverter. At midnight I store the Shelly’s energy counter, and so I can display the daily energy gain from the PV inverter in the Victron console:

[
    {
        "id": "9b8d5eacacb78531",
        "type": "tab",
        "label": "TomsBKW",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c16a0bfd8dee5cea",
        "type": "victron-virtual",
        "z": "9b8d5eacacb78531",
        "name": "TomsBKW",
        "outputs": 1,
        "device": "pvinverter",
        "default_values": true,
        "battery_capacity": 25,
        "include_battery_temperature": 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": "1",
        "pvinverter_nrofphases": 1,
        "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,
        "x": 120,
        "y": 60,
        "wires": [
            []
        ]
    },
    {
        "id": "35275ec1f27f2af7",
        "type": "victron-output-custom",
        "z": "9b8d5eacacb78531",
        "service": "com.victronenergy.pvinverter/101",
        "path": "/Ac/L1/Power",
        "serviceObj": {
            "service": "com.victronenergy.pvinverter/101",
            "name": "TomsBKW (101)"
        },
        "pathObj": {
            "path": "/Ac/L1/Power",
            "name": "/Ac/L1/Power",
            "type": "number",
            "value": 11.3
        },
        "name": "",
        "onlyChanges": false,
        "outputs": 0,
        "x": 790,
        "y": 360,
        "wires": []
    },
    {
        "id": "6a8d240e49b53320",
        "type": "inject",
        "z": "9b8d5eacacb78531",
        "name": "permanent",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "2",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 150,
        "y": 240,
        "wires": [
            [
                "042cf6a11932a8be"
            ]
        ]
    },
    {
        "id": "ce2636d2240cf373",
        "type": "victron-output-custom",
        "z": "9b8d5eacacb78531",
        "service": "com.victronenergy.pvinverter/101",
        "path": "/Ac/L1/Voltage",
        "serviceObj": {
            "service": "com.victronenergy.pvinverter/101",
            "name": "TomsBKW (101)"
        },
        "pathObj": {
            "path": "/Ac/L1/Voltage",
            "name": "/Ac/L1/Voltage",
            "type": "number",
            "value": 0
        },
        "name": "",
        "onlyChanges": false,
        "outputs": 0,
        "x": 800,
        "y": 240,
        "wires": []
    },
    {
        "id": "a7bfe9166a69cb9e",
        "type": "victron-output-custom",
        "z": "9b8d5eacacb78531",
        "service": "com.victronenergy.pvinverter/101",
        "path": "/Ac/L1/Current",
        "serviceObj": {
            "service": "com.victronenergy.pvinverter/101",
            "name": "TomsBKW (101)"
        },
        "pathObj": {
            "path": "/Ac/L1/Current",
            "name": "/Ac/L1/Current",
            "type": "number",
            "value": 0
        },
        "name": "",
        "onlyChanges": false,
        "outputs": 0,
        "x": 800,
        "y": 300,
        "wires": []
    },
    {
        "id": "6a9257942e76f89f",
        "type": "victron-output-custom",
        "z": "9b8d5eacacb78531",
        "service": "com.victronenergy.pvinverter/101",
        "path": "/Ac/Power",
        "serviceObj": {
            "service": "com.victronenergy.pvinverter/101",
            "name": "TomsBKW (101)"
        },
        "pathObj": {
            "path": "/Ac/Power",
            "name": "/Ac/Power",
            "type": "number",
            "value": 0
        },
        "name": "",
        "onlyChanges": false,
        "outputs": 0,
        "x": 780,
        "y": 420,
        "wires": []
    },
    {
        "id": "e5b35642815ff4c2",
        "type": "victron-output-custom",
        "z": "9b8d5eacacb78531",
        "service": "com.victronenergy.pvinverter/101",
        "path": "/Ac/Energy/Forward",
        "serviceObj": {
            "service": "com.victronenergy.pvinverter/101",
            "name": "TomsBKW (101)"
        },
        "pathObj": {
            "path": "/Ac/Energy/Forward",
            "name": "/Ac/Energy/Forward",
            "type": "number",
            "value": 0.025317999999999303
        },
        "name": "",
        "onlyChanges": false,
        "outputs": 0,
        "conditionalMode": false,
        "outputTrue": "",
        "outputFalse": "",
        "debounce": "",
        "x": 810,
        "y": 480,
        "wires": []
    },
    {
        "id": "b53fdec136fc0d9b",
        "type": "inject",
        "z": "9b8d5eacacb78531",
        "name": "atMidNight",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "01 00 * * *",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 150,
        "y": 160,
        "wires": [
            [
                "712dd5e3c5be2f7a"
            ]
        ]
    },
    {
        "id": "905529d86a6c8c30",
        "type": "change",
        "z": "9b8d5eacacb78531",
        "name": "EnergyMidNight",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.switch0.aenergy.total",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 160,
        "wires": [
            [
                "9ab0ab5738569f61"
            ]
        ]
    },
    {
        "id": "9ab0ab5738569f61",
        "type": "change",
        "z": "9b8d5eacacb78531",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "dailystart",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 670,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "042cf6a11932a8be",
        "type": "shelly-gen2",
        "z": "9b8d5eacacb78531",
        "hostname": "192.168.1.98",
        "description": "TomsBKW",
        "mode": "polling",
        "verbose": false,
        "server": "",
        "outputmode": "event",
        "uploadretryinterval": 5000,
        "pollinginterval": 5000,
        "pollstatus": false,
        "getstatusoncommand": true,
        "devicetype": "S3SW-001P16EU",
        "devicetypemustmatchexactly": true,
        "captureblutooth": false,
        "outputs": 1,
        "x": 310,
        "y": 240,
        "wires": [
            [
                "5132accc2b308517"
            ]
        ]
    },
    {
        "id": "712dd5e3c5be2f7a",
        "type": "shelly-gen2",
        "z": "9b8d5eacacb78531",
        "hostname": "192.168.1.98",
        "description": "TomsBKW",
        "mode": "polling",
        "verbose": false,
        "server": "",
        "outputmode": "event",
        "uploadretryinterval": 5000,
        "pollinginterval": 5000,
        "pollstatus": false,
        "getstatusoncommand": true,
        "devicetype": "S3SW-001P16EU",
        "devicetypemustmatchexactly": true,
        "captureblutooth": false,
        "outputs": 1,
        "x": 310,
        "y": 160,
        "wires": [
            [
                "905529d86a6c8c30"
            ]
        ]
    },
    {
        "id": "5132accc2b308517",
        "type": "function",
        "z": "9b8d5eacacb78531",
        "name": "Split BKW data",
        "func": "let voltage = msg.payload.switch0.voltage;\nlet current = msg.payload.switch0.current;\nlet power = Math.abs(msg.payload.switch0.apower);\nlet energy = msg.payload.switch0.aenergy.total;\n\nlet startvalue = flow.get('dailystart') || 0;\nenergy = (energy - startvalue) / 1000.0;\n\nglobal.set ('pv_inverter', power);\n\nreturn [\n    {payload: voltage},\n    {payload: current},\n    {payload: power},\n    {payload: energy}\n];",
        "outputs": 4,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 320,
        "y": 400,
        "wires": [
            [
                "9553977e9932e6f1"
            ],
            [
                "a0d07accd66352e6"
            ],
            [
                "83bd7b882b32efca"
            ],
            [
                "677c58173e46c816"
            ]
        ]
    },
    {
        "id": "677c58173e46c816",
        "type": "rbe",
        "z": "9b8d5eacacb78531",
        "name": "",
        "func": "deadband",
        "gap": "0.001",
        "start": "",
        "inout": "out",
        "septopics": false,
        "property": "payload",
        "topi": "topic",
        "x": 560,
        "y": 480,
        "wires": [
            [
                "e5b35642815ff4c2"
            ]
        ]
    },
    {
        "id": "83bd7b882b32efca",
        "type": "rbe",
        "z": "9b8d5eacacb78531",
        "name": "",
        "func": "deadband",
        "gap": "1",
        "start": "",
        "inout": "out",
        "septopics": false,
        "property": "payload",
        "topi": "topic",
        "x": 560,
        "y": 360,
        "wires": [
            [
                "6a9257942e76f89f",
                "35275ec1f27f2af7"
            ]
        ]
    },
    {
        "id": "a0d07accd66352e6",
        "type": "rbe",
        "z": "9b8d5eacacb78531",
        "name": "",
        "func": "deadband",
        "gap": "0.1",
        "start": "",
        "inout": "out",
        "septopics": false,
        "property": "payload",
        "topi": "topic",
        "x": 560,
        "y": 300,
        "wires": [
            [
                "a7bfe9166a69cb9e"
            ]
        ]
    },
    {
        "id": "9553977e9932e6f1",
        "type": "rbe",
        "z": "9b8d5eacacb78531",
        "name": "",
        "func": "deadband",
        "gap": "1",
        "start": "",
        "inout": "out",
        "septopics": false,
        "property": "payload",
        "topi": "topic",
        "x": 560,
        "y": 240,
        "wires": [
            [
                "ce2636d2240cf373"
            ]
        ]
    },
    {
        "id": "7feee513b94636fb",
        "type": "global-config",
        "env": [],
        "modules": {
            "@victronenergy/node-red-contrib-victron": "1.6.64",
            "node-red-contrib-shelly": "11.7.5"
        }
    }
]

Getting the data can easily be done by using four template nodes with the following code:

{{payload.apower}}

{{payload.voltage}}

{{payload.current}}

{{payload.aenergy.total}}