# Forward complete Message Object to MQTT

**URL:** <https://discourse.nodered.org/t/forward-complete-message-object-to-mqtt/41470>\
**Category:** General\
**Created:** [23 February 2021 10:04 UTC](https://discourse.nodered.org/t/forward-complete-message-object-to-mqtt/41470 "2021-02-23T10:04:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![habnefrage](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/habnefrage/32/37694_2.png) [@habnefrage](https://discourse.nodered.org/u/habnefrage)\
**Post date:** [23 February 2021 10:04 UTC](https://discourse.nodered.org/t/forward-complete-message-object-to-mqtt/41470/1 "2021-02-23T10:04:15Z")

</div>

Hi,  
i am playing with Node-Red on a raspberrymatic.  
I receive messages from rpc-event (when windo opens or shutter closes or so). I connected this block to the MQTT sender. It all works and I can receive the values from Payload.  
BUT I would like to receive the full message object, not only the payload with the 1 or 0 (open or closed).

Could tell me, how to put the full message object into the mqtt broker.

thanks

---

<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:** [23 February 2021 10:34 UTC](https://discourse.nodered.org/t/forward-complete-message-object-to-mqtt/41470/2 "2021-02-23T10:34:32Z")

</div>

Welcome to the forum @habnefrage.

Put whatever you want into msg.payload. So, for example if you want msg.payload, msg.x, and msg.y then one way would be to feed it through a Change node configured to  
Move msg.payload To msg.payload.payload  
Move msg.x To msg.payload.x  
Mover msg.y To msg.payload.y  
and feed it to the MQTT node. Then if you are reading it in an MQTT In node configure it to Output a parsed JSON Object and then in you will get everything you need in the payload, and can reconstruct the original message if that is what you need.

---

<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:** [23 February 2021 10:42 UTC](https://discourse.nodered.org/t/forward-complete-message-object-to-mqtt/41470/3 "2021-02-23T10:42:01Z")

</div>

You could also clone the msg and move it to payload using a function node, if you want everything.

```auto
let hold=RED.util.cloneMessage(msg);
msg.payload = hold
return msg;

```

---

<div class="post-metadata">

**Author:** ![habnefrage](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/habnefrage/32/37694_2.png) [@habnefrage](https://discourse.nodered.org/u/habnefrage)\
**Post date:** [23 February 2021 11:10 UTC](https://discourse.nodered.org/t/forward-complete-message-object-to-mqtt/41470/4 "2021-02-23T11:10:51Z")

</div>

Hammer!  
Both approaches work. Thanks!

---

<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:** [9 March 2021 11:11 UTC](https://discourse.nodered.org/t/forward-complete-message-object-to-mqtt/41470/5 "2021-03-09T11:11:18Z")

</div>

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