Trying to add two inputs, but not sure how

Here is what I have pieced together, but not sure what I'm doing here, not getting any output to the debug?

[
    {
        "id": "6d7c3b91d83d126b",
        "type": "function",
        "z": "f672d0ac69fd5b97",
        "name": "function 4",
        "func": "var temp = (msg.payload.solar1[2]) + (msg.payload.solar2[2])\nmsg.payload = temp;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 760,
        "y": 800,
        "wires": [
            [
                "eb237cb28b7f1809"
            ]
        ]
    },
    {
        "id": "7f4787605eed55ed",
        "type": "change",
        "z": "f672d0ac69fd5b97",
        "name": "solar 2",
        "rules": [
            {
                "t": "set",
                "p": "payload.solar2",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 820,
        "wires": [
            [
                "6d7c3b91d83d126b",
                "0a5716f2b228d0a8"
            ]
        ]
    },
    {
        "id": "1bf92e4a2cae2cc4",
        "type": "change",
        "z": "f672d0ac69fd5b97",
        "name": "solar 1",
        "rules": [
            {
                "t": "set",
                "p": "payload.solar1",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 780,
        "wires": [
            [
                "6d7c3b91d83d126b",
                "a30c261616a90884"
            ]
        ]
    },
    {
        "id": "eb237cb28b7f1809",
        "type": "debug",
        "z": "f672d0ac69fd5b97",
        "name": "debug 21",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 920,
        "y": 800,
        "wires": []
    },
    {
        "id": "0a5716f2b228d0a8",
        "type": "debug",
        "z": "f672d0ac69fd5b97",
        "name": "debug 22",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 720,
        "y": 840,
        "wires": []
    },
    {
        "id": "a30c261616a90884",
        "type": "debug",
        "z": "f672d0ac69fd5b97",
        "name": "debug 23",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 720,
        "y": 760,
        "wires": []
    }
]

A fundamental point to be aware of in Node-RED is that messages NEVER arrive from two separate wires into a node at the same time.

With that in mind, you need some way to join the two incoming messages into 1 msg so that you can access both properties at the same time. Luckily, there is a join node for this very purpose

image

See this article in the cookbook for an example of how to join messages into one object.

1 Like

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