# Configure topics MQTT OUT node

**URL:** <https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706>\
**Category:** General\
**Tags:** home-assistant\
**Created:** [24 February 2023 18:11 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706 "2023-02-24T18:11:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [24 February 2023 18:11 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/1 "2023-02-24T18:11:35Z")

</div>

Good evening  
I'm setting up to receive data from a solar inverter through nodered.  
I receive a frame of information that I transformed into a table.

 ![Capture d’écran 2023-02-24 à 19.06.16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/ab68485f77f50a3249fdec1cdccc7a31af9afb7d.jpeg)

I want to send this data through the MQTT OUT node but I can't configure it to create a payload per information.  
This information arrives en bloc on the MQTT broker of my Home assistant.

 ![Capture d’écran 2023-02-24 à 19.17.24](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/ae5233758b3268bd33d942ae6c82501908b80922.jpeg)

If anyone can advise me, that would be great.

THANKS

---

<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:** [24 February 2023 18:18 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/2 "2023-02-24T18:18:17Z")

</div>

If you want to send each array element to the same mqtt topic then slpit it with a split node, or possible use the split you already have, before the join.

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [24 February 2023 18:58 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/3 "2023-02-24T18:58:11Z")

</div>

I don't know how to do this

---

<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:** [24 February 2023 19:18 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/4 "2023-02-24T19:18:24Z")

</div>

Then you really need to read the documents and watch the video [here](https://nodered.org/docs/user-guide/)

There is also a cookbook example of [Splitting an array](https://cookbook.nodered.org/basic/operate-on-array)

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [25 February 2023 11:50 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/5 "2023-02-25T11:50:56Z")

</div>

Thank you very much so I manage to have all the data in unicast then in array and vice versa.  
Now I don't know how to configure the MQTT OUT node to send to home assistant in topics like this:

 ![Capture d’écran 2023-02-25 à 12.48.53](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/5/d53511e0d066411792e2eaab14ea50407370b0c7.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:** [25 February 2023 15:48 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/6 "2023-02-25T15:48:56Z")

</div>

Please show us the arrays in a copyable form, and where they are in the flow, so i can make you an example  
Use the copy value icon described [here](https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message)

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [25 February 2023 16:04 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/7 "2023-02-25T16:04:17Z")

</div>

```auto
["(231.4",50,230.1,50,"0782","0675","009",376,51.3,"000","041","0037","00.3","090.0","00.00","00010","00010110","00","00","00035","010��"]

```

Like this ?

 ![Capture d’écran 2023-02-25 à 17.02.24](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3fa4199a6d19153dc83183459053b5d18a755ce9.jpeg)

data retrieved from "join" 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:** [25 February 2023 16:05 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/8 "2023-02-25T16:05:52Z")

</div>

And what are the mqtt topics, how do they relate to the array elements?

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [25 February 2023 16:08 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/9 "2023-02-25T16:08:43Z")

</div>

in fact this is where I don't know what and how to do, I ask myself the same question

where can i find this information

---

<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:** [25 February 2023 16:11 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/10 "2023-02-25T16:11:37Z")

</div>

If this is home assistant I can not help, as i do not use it.  
Maybe ask on the HA forum. If you can discover the topics you wish to send to, i can then help further.

---

<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:** [25 February 2023 16:25 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/11 "2023-02-25T16:25:07Z")

</div>

Show us the data that you start with from the inverter.

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [25 February 2023 17:21 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/12 "2023-02-25T17:21:39Z")

</div>

```auto
(229.5 49.9 230.2 50.0 0897 0789 011 368 50.40 000 032 0035 00.0 000.0 00.00 00016 00010000 00 00 00000 010��

```

There

---

<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:** [25 February 2023 19:00 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/13 "2023-02-25T19:00:46Z")

</div>

Are there some docs to tell you what the numbers mean?

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [25 February 2023 19:54 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/14 "2023-02-25T19:54:09Z")

</div>

![Capture d’écran 2023-02-25 à 20.51.59](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/656d5174497a5f0a5fa848b70701377e7e200a44.png)

 ![Capture d’écran 2023-02-25 à 20.52.42](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b1f4b66142092f04991c0067af6fc81492d45c2e.png)

---

<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:** [25 February 2023 20:40 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/15 "2023-02-25T20:40:41Z")

</div>

I think you could use a CSV node to split the data up and create an object with named properties.

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [25 February 2023 21:04 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/16 "2023-02-25T21:04:14Z")

</div>

So the idea is to send a topic for each of the array values you have parsed after the join node.

You push it into a "change node", inside it you create a msg.topic as you want. Then you send all this in the MQTT out.  
Here is an example that pushes the value (msg.payload) of the photovoltaic voltage.  
 ![Capture d’écran du 2023-02-25 21-29-33](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a57e310d97b47868183276097f12ec57f63504b8.png)  
 ![Capture d’écran du 2023-02-25 21-29-49](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b9d9f2ec5828d682a84abb98ae7ec236b8db56c.png)  
 ![Capture d’écran du 2023-02-25 21-30-07](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/708fa0357835773b7af631f28e4eb8e35f6208fe.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:** [25 February 2023 21:38 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/17 "2023-02-25T21:38:03Z")

</div>

I don,t know what topics you wish to send to, but here is an example i think may help

I removed the `(` and `��`  
from the incoming string, and parsed by the csv node, you can give each value a name in column input field. I have just named them `a` to `u`, you can omit values by removing the name but leave the commas. In the csv node example i removed `e`.

The topics i have dynamically created with a string and the value's name that is entered in the csv node. e,g, `my/unique/topic/a` to `my/unique/topic/u`

example

```auto
[{"id":"c7b2ae1208cd57f5","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"(229.5 49.9 230.2 50.0 0897 0789 011 368 50.40 000 032 0035 00.0 000.0 00.00 00016 00010000 00 00 00000 010��\"","payloadType":"json","x":150,"y":440,"wires":[["d76a3f354a1061b6"]]},{"id":"d76a3f354a1061b6","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substringBefore($substringAfter($$.payload, \"(\"),\"��\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":480,"wires":[["31c2626a7557ccf8"]]},{"id":"31c2626a7557ccf8","type":"csv","z":"65617ffeb779f51c","name":"","sep":" ","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"a,b,c,d,,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":450,"y":480,"wires":[["33bdcc643ff92f79"]]},{"id":"33bdcc643ff92f79","type":"split","z":"65617ffeb779f51c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":190,"y":540,"wires":[["5d7d8b5fa42333b4"]]},{"id":"5d7d8b5fa42333b4","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"mt/unique/topic/\" & $$.parts.key","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":540,"wires":[["2917b89b0a387815"]]},{"id":"2917b89b0a387815","type":"debug","z":"65617ffeb779f51c","name":"mqtt node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":540,"wires":[]}]

```

Hope it helps

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [25 February 2023 21:52 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/18 "2023-02-25T21:52:11Z")

</div>

whooohh the change node for the msg.topic is impressive

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [25 February 2023 23:12 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/19 "2023-02-25T23:12:42Z")

</div>

it works like thunder

---

<div class="post-metadata">

**Author:** ![Septain21](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/septain21/32/76690_2.png) [@Septain21](https://discourse.nodered.org/u/Septain21)\
**Post date:** [26 February 2023 18:56 UTC](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706/20 "2023-02-26T18:56:39Z")

</div>

Now I want to configure my MQTT OUT node for each information like this:

- Configuration topic: homeassistant/sensor/Grid-Voltage/config

- Configuration payload no1: {"name": "Grid Voltage", "device\_class": "voltage", "object\_id": "Grid\_Voltage","unique\_id": "Grid\_Voltage" ,"state\_topic": "homeassistant/sensor/Grid-Voltage/state", "unit\_of\_measurement": "V", "value\_template": "{{ value}}" }

- Configuration topic: homeassistant/sensor/Grid-Frequency/config

- Configuration payload no1: {"name": "Grid Frequency", "device\_class": "frequency", "object\_id": "Grid\_Frequency","unique\_id": "Grid\_Frequency" ,"state\_topic": "homeassistant/sensor/Grid-Frequency/state", "unit\_of\_measurement": "Hz", "value\_template": "{{ value}}" }

............

But where do i enter this information ?

[Next page](https://discourse.nodered.org/t/configure-topics-mqtt-out-node/75706.md?page=2)
