# Start Stop Payload passthrogh

**URL:** <https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999>\
**Category:** General\
**Created:** [31 December 2022 17:40 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999 "2022-12-31T17:40:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phoenix](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@Phoenix](https://discourse.nodered.org/u/Phoenix)\
**Post date:** [31 December 2022 17:40 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/1 "2022-12-31T17:40:28Z")

</div>

Dear Node Red Forum Team,  
I am a beginner in Node Red programming, really nice, I like it.  
I would need your help about creating a Node for my new project and don't really find any information on the internet how to realize the following sketch.  
I have a 3 phase solar system which measures the consumption in W.  
I use sum to get them in one data and the power-monitor to calculate in kWh.

What I need is "switch" when the inverter switches from sun to bypass, the calculated kWh should be outputted to another data point. I would try to draw what I have in mind.

3 data inputs - sum - "switch" "when on sun power" -w to kWh - data point to InfluxDB  
"when on grid power" -w to kWh - data point to InfluxDB

I also have no experience with JavaScript.

Thank you very much in advance for your help.

Happy New Year!

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [31 December 2022 20:00 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/2 "2022-12-31T20:00:45Z")

</div>

Hello @Phoenix, welcome to Node-red.

Note that a group of nodes joined together by wires, down which data messages flow is called a Flow, not a Node.

Looks like you have two challenges to tackle.

Most nodes can only process a single message at a time. Once it has been sent to the output, everything about it is forgotten.  
So you can't just add up the values from three inputs.  
The usual way to tackle it is to give each input a different msg.topic. Depending how they arrive into the flow (eg by mqtt), they may already have this. Then fed them into a Join node set to "manual join". This will give you a single message with all three values. Then you save to add them up.

The second challenge: a second output when on grid power is also possible using msg.topic and a Switch node set to test msg.topic.

Good luck!

Ps. You can do nearly everything in Node-red without using JavaScript. If there is something you can't master just using core and contributed nodes but you can do it with one hand tied behind your back in Python, C, Bash, etc,v it's easy to patch in external executables with the Exec node.

---

<div class="post-metadata">

**Author:** ![Phoenix](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@Phoenix](https://discourse.nodered.org/u/Phoenix)\
**Post date:** [31 December 2022 20:40 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/3 "2022-12-31T20:40:12Z")

</div>

Hello @jbudd,  
thanks for the prompt reply.  
I know it's a Flow, sorry for that.  
Forgot to mention that the "switch" needs to be change from a different node.  
I will try to make a schematic, maybe it will be easier to understand.

 ![Screenshot 2022-12-31 213413](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/4245b3e8784fc654345c24070bbed96f58fde99f.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [31 December 2022 21:29 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/4 "2022-12-31T21:29:27Z")

</div>

Have a search for " node-red-contrib-simple-gate" in node library.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [31 December 2022 21:34 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/5 "2022-12-31T21:34:43Z")

</div>

![Untitled 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/0/b0895acf1eca68e3a3c2882e28f88ec8934792bd.jpeg)  
This suggests that you don't understand about each message being processed completely independently. Your "grid/sun switch" cannot change how WR[1-3] are handled.

 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d4a31951f128ef38caeabdfa442becbec9a3766.jpeg)

I don't recognise your "Math" node so I don't know if it's capable of adding up the three inputs.

---

<div class="post-metadata">

**Author:** ![Phoenix](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@Phoenix](https://discourse.nodered.org/u/Phoenix)\
**Post date:** [31 December 2022 22:27 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/6 "2022-12-31T22:27:31Z")

</div>

@E1cid this is exactly what I need.  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![Phoenix](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@Phoenix](https://discourse.nodered.org/u/Phoenix)\
**Post date:** [1 January 2023 10:29 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/7 "2023-01-01T10:29:12Z")

</div>

HAPPY NEW YEAR!!!

I've solved it like this:

```auto
[
    {
        "id": "c89231cf7bc89672",
        "type": "power-monitor",
        "z": "a0ffbde30d80ea16",
        "name": "Sunpower",
        "startthreshold": 0,
        "stopthreshold": 0,
        "startafter": 1,
        "stopafter": 1,
        "energydecimals": 4,
        "emitidle": true,
        "x": 760,
        "y": 2140,
        "wires": [
            [
                "d5a54472a201cbdc"
            ]
        ]
    },
    {
        "id": "cd2091a50475dec8",
        "type": "ioBroker in",
        "z": "a0ffbde30d80ea16",
        "name": "WR1 out W",
        "topic": "modbus.0.inputRegisters.1.30011_WR1_Output_Active_Power",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "fireOnStart": "false",
        "outFormat": "MQTT",
        "x": 110,
        "y": 2080,
        "wires": [
            [
                "40fba0e03b4fc497"
            ]
        ]
    },
    {
        "id": "41efb2dbbfa7137d",
        "type": "ioBroker in",
        "z": "a0ffbde30d80ea16",
        "name": "WR2 out W",
        "topic": "modbus.0.inputRegisters.2.30011_WR2_Output_Active_Power",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "fireOnStart": "false",
        "outFormat": "MQTT",
        "x": 110,
        "y": 2140,
        "wires": [
            [
                "40fba0e03b4fc497"
            ]
        ]
    },
    {
        "id": "a127358e0172d4c2",
        "type": "ioBroker in",
        "z": "a0ffbde30d80ea16",
        "name": "WR3 out W",
        "topic": "modbus.0.inputRegisters.3.30011_WR3_Output_Active_Power",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "fireOnStart": "false",
        "outFormat": "MQTT",
        "x": 110,
        "y": 2200,
        "wires": [
            [
                "40fba0e03b4fc497"
            ]
        ]
    },
    {
        "id": "40fba0e03b4fc497",
        "type": "SumUltimate",
        "z": "a0ffbde30d80ea16",
        "name": "Math",
        "property": "payload",
        "math": "sum",
        "x": 370,
        "y": 2140,
        "wires": [
            [
                "2a499531e3138ce8",
                "9b35d3a4ef0539a1"
            ]
        ]
    },
    {
        "id": "d5a54472a201cbdc",
        "type": "change",
        "z": "a0ffbde30d80ea16",
        "name": "kWh-filter",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.energy",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 940,
        "y": 2140,
        "wires": [
            [
                "bdd8fabfbf06033d"
            ]
        ]
    },
    {
        "id": "d95d01336f6e8475",
        "type": "ioBroker in",
        "z": "a0ffbde30d80ea16",
        "name": "WR1 Status",
        "topic": "modbus.0.inputRegisters.1.30001_WR1_System_Status",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "fireOnStart": "false",
        "outFormat": "MQTT",
        "x": 110,
        "y": 2020,
        "wires": [
            [
                "4397f011ef4eda1d",
                "a21e3f46ba6a5266"
            ]
        ]
    },
    {
        "id": "2a499531e3138ce8",
        "type": "gate",
        "z": "a0ffbde30d80ea16",
        "name": "",
        "controlTopic": "control",
        "defaultState": "open",
        "openCmd": "open",
        "closeCmd": "close",
        "toggleCmd": "toggle",
        "defaultCmd": "default",
        "statusCmd": "status",
        "persist": false,
        "storeName": "memory",
        "x": 610,
        "y": 2140,
        "wires": [
            [
                "c89231cf7bc89672"
            ]
        ]
    },
    {
        "id": "9b35d3a4ef0539a1",
        "type": "gate",
        "z": "a0ffbde30d80ea16",
        "name": "",
        "controlTopic": "control",
        "defaultState": "open",
        "openCmd": "open",
        "closeCmd": "close",
        "toggleCmd": "toggle",
        "defaultCmd": "default",
        "statusCmd": "status",
        "persist": false,
        "storeName": "memory",
        "x": 610,
        "y": 2060,
        "wires": [
            [
                "e2b365800f85f979"
            ]
        ]
    },
    {
        "id": "e2b365800f85f979",
        "type": "power-monitor",
        "z": "a0ffbde30d80ea16",
        "name": "Gridpower",
        "startthreshold": 0,
        "stopthreshold": 0,
        "startafter": 1,
        "stopafter": 1,
        "energydecimals": 4,
        "emitidle": true,
        "x": 770,
        "y": 2060,
        "wires": [
            [
                "5dae14685eec6ad9"
            ]
        ]
    },
    {
        "id": "5dae14685eec6ad9",
        "type": "change",
        "z": "a0ffbde30d80ea16",
        "name": "kWh-filter",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.energy",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 940,
        "y": 2060,
        "wires": [
            [
                "ac128e4e63a2e37b"
            ]
        ]
    },
    {
        "id": "4397f011ef4eda1d",
        "type": "function",
        "z": "a0ffbde30d80ea16",
        "name": "12 = open",
        "func": "if (msg.payload === 12)\n msg.payload = \"open\";\n\nelse msg.payload = \"close\";\nmsg.topic = \"control\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 380,
        "y": 2100,
        "wires": [
            [
                "2a499531e3138ce8"
            ]
        ]
    },
    {
        "id": "a21e3f46ba6a5266",
        "type": "function",
        "z": "a0ffbde30d80ea16",
        "name": "12 = close",
        "func": "if (msg.payload === 12)\n msg.payload = \"close\";\n\nelse msg.payload = \"open\";\nmsg.topic = \"control\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 390,
        "y": 2060,
        "wires": [
            [
                "9b35d3a4ef0539a1"
            ]
        ]
    },
    {
        "id": "e65615fc24e4335b",
        "type": "ioBroker out",
        "z": "a0ffbde30d80ea16",
        "name": "Sonne",
        "topic": "0_userdata.0.PV_Anlage.WR.Aus_Sonne_Verbraucht",
        "ack": "true",
        "autoCreate": "false",
        "stateName": "",
        "role": "",
        "payloadType": "",
        "readonly": "",
        "stateUnit": "",
        "stateMin": "",
        "stateMax": "",
        "x": 1230,
        "y": 2140,
        "wires": []
    },
    {
        "id": "9e8d2a77f258a878",
        "type": "ioBroker out",
        "z": "a0ffbde30d80ea16",
        "name": "Netz",
        "topic": "0_userdata.0.PV_Anlage.WR.Aus_Netz_Verbraucht",
        "ack": "true",
        "autoCreate": "false",
        "stateName": "",
        "role": "",
        "payloadType": "",
        "readonly": "",
        "stateUnit": "",
        "stateMin": "",
        "stateMax": "",
        "x": 1230,
        "y": 2060,
        "wires": []
    },
    {
        "id": "ac128e4e63a2e37b",
        "type": "delay",
        "z": "a0ffbde30d80ea16",
        "name": "1/s",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 1090,
        "y": 2060,
        "wires": [
            [
                "9e8d2a77f258a878"
            ]
        ]
    },
    {
        "id": "bdd8fabfbf06033d",
        "type": "delay",
        "z": "a0ffbde30d80ea16",
        "name": "1/s",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 1090,
        "y": 2140,
        "wires": [
            [
                "e65615fc24e4335b"
            ]
        ]
    }
]

```

Thank you all for your help.  
BR  
Phoenix

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 March 2023 10:29 UTC](https://discourse.nodered.org/t/start-stop-payload-passthrogh/72999/8 "2023-03-02T10:29:58Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
