# Cant Add a own value Number to an Object Payload

**URL:** https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321
**Category:** General
**Created:** [19 June 2026 11:52 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321 "2026-06-19T11:52:01Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)
#### Post date: [19 June 2026 11:52 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/1 "2026-06-19T11:52:01Z")

</div>

Hi,

i have a Problem to add in a function Node to a Msg.Payload (is an Object) a normal value like a Number.

Its to add the Total Watthours from an old Inverter to the New Inverters Value:

```auto
var time = new Date();
var totalkwh = msg.payload["opendtu/12123/0/yieldtotal"];
var field1 = "totalkwh";

var totalkwhnew = totalkwh+1544;
msg.params = [time, totalkwhnew, field1];

return msg;

```

The 1544 are not added but why ?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [19 June 2026 11:57 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/2 "2026-06-19T11:57:16Z")

</div>

You are not putting `1544` into `msg.payload`

Have you set the debug to output the complete message?

What do you see in debug panel if you change code to this:

```js
var time = new Date();
var totalkwh = msg.payload["opendtu/12123/0/yieldtotal"];
var field1 = "totalkwh";
var totalkwhnew = totalkwh+1544;

msg.params = [time, totalkwhnew, field1];

msg.warn({ totalkwh, totalkwhnew, payload: msg.payload, params: msg.params })

return msg;

```

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [19 June 2026 12:17 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/3 "2026-06-19T12:17:02Z")

</div>

Try this...

```auto
var time = new Date();

var totalkwh = Number(msg.payload["opendtu/12123/0/yieldtotal"]);

if (isNaN(totalkwh)) {
    node.error("yieldtotal is not a number");
    return null;
}

var field1 = "totalkwh";
var totalkwhnew = totalkwh + 1544;

msg.params = [time, totalkwhnew, field1];

return msg;

```

---

<div class="post-metadata">

### Author: ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)
#### Post date: [19 June 2026 12:29 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/4 "2026-06-19T12:29:48Z")

</div>

> [@dynamicdave](#):
>
> ```auto
> var time = new Date();
> 
> var totalkwh = Number(msg.payload["opendtu/12123/0/yieldtotal"]);
> 
> if (isNaN(totalkwh)) {
> node.error("yieldtotal is not a number");
> return null;
> }
> 
> var field1 = "totalkwh";
> var totalkwhnew = totalkwh + 1544;
> 
> msg.params = [time, totalkwhnew, field1];
> 
> return msg;
> 
> ```

It appears to bypass the function node without effect.

I think it's a problem with the join node before the function node

---

<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: [19 June 2026 12:38 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/5 "2026-06-19T12:38:52Z")

</div>

Post deleted

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [19 June 2026 12:39 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/6 "2026-06-19T12:39:37Z")

</div>

> [@Starfoxfs](#):
>
> It appears to bypass the function node without effect.
> 
> I think it's a problem with the join node before the function node

Maybe _we_ need to check the _value_ of `msg.payload["opendtu/12123/0/yieldtotal"]`

@dynamicdave put in a _check_ that exits if it is not a number. (`NaN`)

So if it isn't a number, it will just exit.

Are you seeing/getting the `node.error("yieldtotal is not a number");` message?

---

<div class="post-metadata">

### Author: ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)
#### Post date: [19 June 2026 12:44 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/7 "2026-06-19T12:44:26Z")

</div>

Yes i get this if i set the Join Node to Array or String, if i set the Join Node (before the Function Node) to "a key /value Object " with msg.topic as the key then it bypass the function Node and i dont see the `node.error("yieldtotal is not a number");`

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 June 2026 12:45 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/8 "2026-06-19T12:45:05Z")

</div>

Show us the message going into the function node

---

<div class="post-metadata">

### Author: ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)
#### Post date: [19 June 2026 12:52 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/9 "2026-06-19T12:52:38Z")

</div>

I post the complete JSON:

```auto
[
    {
        "id": "e181ab23ca2013dc",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "a51b2b36cf83199b",
        "type": "mqtt in",
        "z": "e181ab23ca2013dc",
        "name": "",
        "topic": "opendtu/12123/0/yieldtotal",
        "qos": "0",
        "datatype": "json",
        "broker": "722c90e4f8ec0db9",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 270,
        "y": 260,
        "wires": [
            [
                "0184268473772f5f"
            ]
        ]
    },
    {
        "id": "0184268473772f5f",
        "type": "join",
        "z": "e181ab23ca2013dc",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "useparts": true,
        "accumulate": false,
        "timeout": "",
        "count": "1",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 630,
        "y": 240,
        "wires": [
            [
                "d185134d62647599"
            ]
        ]
    },
    {
        "id": "d185134d62647599",
        "type": "function",
        "z": "e181ab23ca2013dc",
        "name": "function 2",
        "func": "var time = new Date();\n\nvar totalkwh = Number(msg.payload[\"opendtu/12123/0/yieldtotal\"]);\n\nif (isNaN(totalkwh)) {\n node.error(\"yieldtotal is not a number\");\n return null;\n}\n\nvar field1 = \"totalkwh\";\nvar totalkwhnew = totalkwh + 1544;\n\nmsg.params = [time, totalkwhnew, field1];\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 860,
        "y": 260,
        "wires": [
            [
                "20ebe008a74ff4f5"
            ]
        ]
    },
    {
        "id": "20ebe008a74ff4f5",
        "type": "debug",
        "z": "e181ab23ca2013dc",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1140,
        "y": 260,
        "wires": []
    },
    {
        "id": "722c90e4f8ec0db9",
        "type": "mqtt-broker",
        "name": "Mqtt Server",
        "broker": "mosquitto",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "5",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

```

Frist Message is from MQTT to Join Node to Function Node to Debug

---

<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: [19 June 2026 12:52 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/10 "2026-06-19T12:52:47Z")

</div>

Edit: _Shrug_

---

<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: [19 June 2026 13:04 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/11 "2026-06-19T13:04:44Z")

</div>

As @Steve-Mcl has mentioned, set the debug to show complete message object, as the result of your addition is in msg.params.

or if you want the result in msg.payload  
change

```auto
msg.params = \[time, totalkwhnew, field1\];

```

to

```auto
msg.payload = [time, totalkwhnew, field1];

```

---

<div class="post-metadata">

### Author: ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)
#### Post date: [19 June 2026 13:35 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/12 "2026-06-19T13:35:15Z")

</div>

This works, but how to insert this into Postgresql ?

My Postgres Node is as follows:

```auto
INSERT INTO solar (time, field1) VALUES ($1, $2),($1, $2);

```

Heres explained only with msg.params

> **[node-red-contrib-postgresql](https://flows.nodered.org/node/node-red-contrib-postgresql)**
>
> Node-RED node for PostgreSQL, supporting parameters, split, back-pressure

---

<div class="post-metadata">

### Author: ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)
#### Post date: [19 June 2026 18:06 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/13 "2026-06-19T18:06:46Z")

</div>

It works with msg.params i just didnt see it because i had a debug node with msg.payload

In the Database its all fine !

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [19 June 2026 18:47 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/14 "2026-06-19T18:47:34Z")

</div>

> [@Steve-Mcl](#):
>
> Have you set the debug to output the complete message

Just saying ^ 😅

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [23 June 2026 10:38 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/15 "2026-06-23T10:38:49Z")

</div>

From my experience setting debug to show entire msg is nr1 most important thing when dragging a new debug node into a flow. Ideally I'll copy an existing one instead to get it configured correctly automatically.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [23 June 2026 10:44 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/16 "2026-06-23T10:44:38Z")

</div>

See this PR already merged into v5 to set default the way you want it.

> <https://github.com/node-red/node-red/pull/5591>
>
> and add commented example to blank settings file
> 
> 
> 
> \- \[\] Bugfix (non-breaki…ng change which fixes an issue)
> \- \[x\] New feature (non-breaking change which adds functionality)
> 
> 
> 
> \## Proposed changes
> 
> As per discussions on forum - this enables the ability for a user to override a nodes default properties by entries in the settings.js file - this is useful for setting up a default way of working for a team to save everyone having to change the default output of the debug node for example - or indeed a single user.
> 
> NOTE: This only changes the defaults - ie the user can still edit the settings in the editor UI - this doesn't lock anything - it just allows changing the defaults for a new dragged on node to something the user may wish to use more often.
> 
> To do this the user adds an entry like this to their settings.js file
> \`\`\`
> nodeDefaults: {
> debug: {
> complete: true,
> console:true,
> active:false
> },
> inject: {
> props: \[{"p":"payload"}\],
> payload: "Hello World",
> payloadType: "str"
> }
> }
> \`\`\`
> 
> 
> 
> 
> \## Checklist
> 
> 
> \- \[x\] I have read the \[contribution guidelines\](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
> \- \[x\] For non-bugfix PRs, I have discussed this change on the forum/slack team.
> \- \[x\] I have run \`npm run test\` to verify the unit tests pass
> \- \[\] I have added suitable unit tests to cover the new/changed functionality

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [23 June 2026 10:45 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/17 "2026-06-23T10:45:10Z")

</div>

Glorious!

---

<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: [7 July 2026 10:45 UTC](https://discourse.nodered.org/t/cant-add-a-own-value-number-to-an-object-payload/101321/18 "2026-07-07T10:45:46Z")

</div>

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