# Output feed returns two values, how do I split it up into two separate strings?

**URL:** https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372
**Category:** General
**Created:** [18 December 2021 00:17 UTC](https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372 "2021-12-18T00:17:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![g00r](https://avatars.discourse-cdn.com/v4/letter/g/da6949/32.png) [@g00r](https://discourse.nodered.org/u/g00r)
#### Post date: [18 December 2021 00:17 UTC](https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372/1 "2021-12-18T00:17:21Z")

</div>

This is the output of my inverter data stream  
 ![nodered](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c773d1b1f9204be4b7117d42d3a1fde6324a8b4a.png)

> {"String\_watts":[654,1595],"Todays\_Yeild":3.801,"Voltage":244.66,"grid\_feedin":0,"grid\_consumption":0,"power":2154,"available\_sessions":1}

The [654,1595] is the problem as it contains two values that are stopping me from feeding it into MQTT.  
What's the best way to go about getting this into the correct format?

Thanks

---

<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: [18 December 2021 00:23 UTC](https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372/2 "2021-12-18T00:23:43Z")

</div>

> [@g00r](#):
>
> What's the best way to go about getting this into the correct format

What is the correct format? You'll need to provide info for us to help you.

That said, some basic node-red info might help you to figure this out.

Canned text . .

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

* * *

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

### Author: ![g00r](https://avatars.discourse-cdn.com/v4/letter/g/da6949/32.png) [@g00r](https://discourse.nodered.org/u/g00r)
#### Post date: [21 December 2021 04:42 UTC](https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372/3 "2021-12-21T04:42:35Z")

</div>

Thanks for the speedy response.

I have taken a look at the guides you've suggested, but I still need a hint as to how best to manipulate this data.

The of the data is my solar inverter. This is being brought into NodeRed with the SMA-Webconnect addon.  
I can configure the data it sources from the inverter through altering the .js file for the plugin, but the watts values for the two MPPT strings come as a package, hence the image I attached.

I am passing the data on to EmonCMS via MQTT and what I want is for the data (string A & B watts) to be broken up into separate objects so that EmonCMS can read them.

Which would be the best function in NodeRed to accomplish this?

Edit: For clarity. Right now I have data flowing directly from the plugin to a MQTT Out node

---

<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: [21 December 2021 09:36 UTC](https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372/4 "2021-12-21T09:36:54Z")

</div>

Here are some specific examples of accessing the array elements in your object, and moving/setting them to other properties. Hope it nudges your gray matter.

```auto
[{"id":"8034f1d4.e672","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"String_watts\":[654,1595],\"Todays_Yeild\":3.801,\"Voltage\":244.66,\"grid_feedin\":0,\"grid_consumption\":0,\"power\":2154,\"available_sessions\":1}","payloadType":"json","x":130,"y":1340,"wires":[["795d8672.ce1a","dc94610d.07b708","539c5327.bfaebc","175b8b89.9b7c24"]]},{"id":"795d8672.ce1a","type":"debug","z":"c791cbc0.84f648","name":"first element of array","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.String_watts[0]","statusType":"msg","x":580,"y":1320,"wires":[]},{"id":"dc94610d.07b708","type":"debug","z":"c791cbc0.84f648","name":"second element of array","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.String_watts[1]","statusType":"msg","x":570,"y":1380,"wires":[]},{"id":"539c5327.bfaebc","type":"change","z":"c791cbc0.84f648","name":"move array element to payload","rules":[{"t":"move","p":"payload.String_watts[1]","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":1460,"wires":[["eadb43e6.8ef57"]]},{"id":"175b8b89.9b7c24","type":"change","z":"c791cbc0.84f648","name":"set array element to payload.s","rules":[{"t":"move","p":"payload.String_watts[0]","pt":"msg","to":"payload.first_watts","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1520,"wires":[["779401e2.363e68"]]},{"id":"eadb43e6.8ef57","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":1460,"wires":[]},{"id":"779401e2.363e68","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.first_watts","statusType":"msg","x":600,"y":1520,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![berijan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/berijan/32/35313_2.png) [@berijan](https://discourse.nodered.org/u/berijan)
#### Post date: [22 December 2021 14:27 UTC](https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372/5 "2021-12-22T14:27:54Z")

</div>

Can You give as an example on how You want the separate object to look like.  
Is it just the number like {658} or is it an object like {value : 658} etc?

---

<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: [20 February 2022 14:28 UTC](https://discourse.nodered.org/t/output-feed-returns-two-values-how-do-i-split-it-up-into-two-separate-strings/55372/6 "2022-02-20T14:28:28Z")

</div>

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