# Change incoming MQTT payload and send it to Tasmota

**URL:** <https://discourse.nodered.org/t/change-incoming-mqtt-payload-and-send-it-to-tasmota/67686>\
**Category:** General\
**Tags:** function-node, mqtt\
**Created:** [14 September 2022 08:23 UTC](https://discourse.nodered.org/t/change-incoming-mqtt-payload-and-send-it-to-tasmota/67686 "2022-09-14T08:23:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fliacik](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Fliacik](https://discourse.nodered.org/u/Fliacik)\
**Post date:** [14 September 2022 08:23 UTC](https://discourse.nodered.org/t/change-incoming-mqtt-payload-and-send-it-to-tasmota/67686/1 "2022-09-14T08:23:14Z")

</div>

Hi there. Please I need help with convert incoming message from my ORNO WE 516 to readable domoticz values.

On input from MQTT i get this message in string form:  
tele/tasmota\_147B98/SENSOR : msg.payload : string[316]  
`{"Time":"2022-09-14T09:05:10","ENERGY":{"TotalStartTime":"2022-09-11T22:36:00","Total":7.050,"Yesterday":3.770,"Today":2.430,"Period":[0, 0, 0],"Power":[6,20,267],"ApparentPower":[71,42,689],"ReactivePower":[0, 0, 1],"Factor":[0.09,0.63,0.40],"Frequency":50,"Voltage":[238,236,237],"Current":[0.300,0.180,2.910]}}`

I need choose one of this values like "Voltage" and send it back to MQTT with message something like this:

```auto
msg1 = {};

msg1.payload = {"command":"udevice","idx":300,"nvalue":0,"svalue":238;236;237}; 
                           
return [[msg1]];

```

For correct read device in Domoticz. Can you help me please how to modifi this MQTT message?

---

<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:** [14 September 2022 08:52 UTC](https://discourse.nodered.org/t/change-incoming-mqtt-payload-and-send-it-to-tasmota/67686/2 "2022-09-14T08:52:56Z")

</div>

1. set the MQTT node to parse JSON into an object
2. click the copy path button on the item of interest
3. use a change node to copy into `msg.payload` from the `msg.path_you_copied`
4. send to an MQTT out node with an appropriate topic

* * *

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) 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)

---

<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:** [14 September 2022 08:56 UTC](https://discourse.nodered.org/t/change-incoming-mqtt-payload-and-send-it-to-tasmota/67686/3 "2022-09-14T08:56:26Z")

</div>

NOTE what you are doing here:

> [@Fliacik](#):
>
> `msg1.payload = {"command":"udevice","idx":300,"nvalue":0,"svalue":238;236;237}`

is not valid.

At a guess you want a string from the voltage array e.g. "238;236;237"

In a function node...

```auto
msg.payload = {
    "command":"udevice",
    "idx":300,
    "nvalue":0,
    "svalue": msg.payload.Voltage.join(';')}; 
}                       
return msg;

```

---

<div class="post-metadata">

**Author:** ![Fliacik](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Fliacik](https://discourse.nodered.org/u/Fliacik)\
**Post date:** [14 September 2022 09:34 UTC](https://discourse.nodered.org/t/change-incoming-mqtt-payload-and-send-it-to-tasmota/67686/4 "2022-09-14T09:34:29Z")

</div>

Steve Huge THANKYOU 🙂

Its works.

![Snímka obrazovky 2022-09-14 o 11.32.08](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf84a7ef752de40d00bf861749f9e2a8c5a2fafb.png)

Tasmota log:  
`2022-09-14 11:33:10.621 MQTT: Topic: domoticz/in, Message: {"command":"udevice","idx":148,"nvalue":0,"svalue":"238,238,239"}`

---

<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:** [28 September 2022 09:35 UTC](https://discourse.nodered.org/t/change-incoming-mqtt-payload-and-send-it-to-tasmota/67686/5 "2022-09-28T09:35:23Z")

</div>

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