# From a mqtt message extract and modify two parameters to create a new one

**URL:** <https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363>\
**Category:** General\
**Created:** [20 March 2020 18:21 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363 "2020-03-20T18:21:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 18:21 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/1 "2020-03-20T18:21:43Z")

</div>

hi, i have a mqtt messge object that is like this:

switch light off  
`{"Battery":255,"RSSI":12,"description":"topic=tasmota_mcp\npayload=MCPINT_D0=","dtype":"Light/Switch","hwid":"6","id":"000140FE","idx":174,"name":"mcp_luce1","nvalue":0,"stype":"Switch","svalue1":"0","switchType":"On/Off","unit":1}`

or switch light on

`{"Battery":255,"RSSI":12,"description":"topic=tasmota_mcp\npayload=MCPINT_D0=","dtype":"Light/Switch","hwid":"6","id":"000140FE","idx":174,"name":"mcp_luce1","nvalue":1,"stype":"Switch","svalue1":"0","switchType":"On/Off","unit":1}`

please note:  
**description** :  
topic=tasmota\_mcp\npayload=MCPINT\_D0=  
and **nvalue**  
1 or 0

from this i need to create a mqtt message like this

message topic =\>\> _cmnd/tasmota\_mcp/event_  
payload=\>\> MCPINT\_D0=1 or 0 this value 1 or 0 is taken from nvalue

so the out mqtt message should be:  
cmnd/tasmota\_mcp/event MCPINT\_D0=1  
or  
cmnd/tasmota\_mcp/event MCPINT\_D0=0

like @Andrei explain in another post i try to make the flow, but i not succeed in two things:

1. how to split the payload, where first part is inside description field and another part is in nvalue field

2. how to divive the description fild and address one part in payload and one part in topic

this is my flow  
`[{"id":"414b2538.26bf1c","type":"inject","z":"250fdc05.cea3b4","name":"luce OFF","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":0,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":100,"wires":[["27269e92.bcea52"]]}]`

thanks for help me

ps. of course the description field is free to change if there are more confortable and clever way to rapresent topic and payload

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 18:47 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/2 "2020-03-20T18:47:18Z")

</div>

Your flow contains only a single `insert` node

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 19:02 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/3 "2020-03-20T19:02:57Z")

</div>

sorry may not export in a proper way:

```auto
[{"id":"250fdc05.cea3b4","type":"tab","label":"luci_tasmota_mcp","disabled":false,"info":""},{"id":"414b2538.26bf1c","type":"inject","z":"250fdc05.cea3b4","name":"luce OFF","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":0,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":100,"wires":[["27269e92.bcea52"]]},{"id":"1c2650ef.d27fc7","type":"inject","z":"250fdc05.cea3b4","name":"luce ON","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":1,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":160,"wires":[["27269e92.bcea52"]]},{"id":"27269e92.bcea52","type":"switch","z":"250fdc05.cea3b4","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"MCPINT","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":220,"wires":[["465a33be.278204","7cfc743f.45f66c"],[]]},{"id":"465a33be.278204","type":"debug","z":"250fdc05.cea3b4","name":"switch MCP","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":590,"y":120,"wires":[]},{"id":"bbbb7cce.636cd8","type":"mqtt in","z":"250fdc05.cea3b4","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f0a64cae.6413e","x":230,"y":40,"wires":[[]]},{"id":"15a19111.be99b7","type":"mqtt out","z":"250fdc05.cea3b4","name":"","topic":"","qos":"","retain":"","broker":"f0a64cae.6413e","x":750,"y":220,"wires":[]},{"id":"7cfc743f.45f66c","type":"change","z":"250fdc05.cea3b4","name":"JSONata","rules":[{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/event\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"topic_first","pt":"msg","to":"$split(part3, \"payload=\")\t","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"topic_first","tot":"jsonata"},{"t":"set","p":"payload_end","pt":"msg","to":"payload.nvalue","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":220,"wires":[["435d34f4.55b4e4","1f1b20a0.520687","ec882e8.23642d"]]},{"id":"435d34f4.55b4e4","type":"debug","z":"250fdc05.cea3b4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":630,"y":340,"wires":[]},{"id":"1f1b20a0.520687","type":"debug","z":"250fdc05.cea3b4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":620,"y":420,"wires":[]},{"id":"ec882e8.23642d","type":"split","z":"250fdc05.cea3b4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":350,"y":320,"wires":[["b39e77ba.1b797","d1c27cc4.e97dc8"]]},{"id":"b39e77ba.1b797","type":"change","z":"250fdc05.cea3b4","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"},{"t":"move","p":"payload_end","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":380,"wires":[["d7c28836.be152","d79a960b.204508","5c17d0cf.94dbc8"]]},{"id":"d1c27cc4.e97dc8","type":"debug","z":"250fdc05.cea3b4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":380,"y":540,"wires":[]},{"id":"d7c28836.be152","type":"debug","z":"250fdc05.cea3b4","name":"Connect to the MQTT out node","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":500,"wires":[]},{"id":"d79a960b.204508","type":"debug","z":"250fdc05.cea3b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":590,"y":540,"wires":[]},{"id":"5c17d0cf.94dbc8","type":"debug","z":"250fdc05.cea3b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":580,"wires":[]},{"id":"f0a64cae.6413e","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.0.105","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 20:58 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/4 "2020-03-20T20:58:04Z")

</div>

i try to create another flow...  
now i succeed on having topic like: **cmnd/tasmota\_mcp/event**

and payload like: **MCPINT\_D0=0**

but there comes from two different line and when i combine to connect mqtt out i receive an error.  
this is the log:

```auto
20/3/2020, 21:55:19[node: 2095d260.787b0e](http://192.168.0.105:1880/#)

cmnd/tasmota_mcp/event : msg.topic : string[22]

"cmnd/tasmota_mcp/event"

20/3/2020, 21:55:19[node: b47806c4.7b80f8](http://192.168.0.105:1880/#)msg.payload : string[11]

"MCPINT_D0=0"

20/3/2020, 21:55:19[node: 7b401d4f.46369c](http://192.168.0.105:1880/#)msg : string[23]

"Invalid topic specified"

```

this is the flow:

```auto
[{"id":"2019e3ca.87d34c","type":"tab","label":"luci_tasmota_mcp","disabled":false,"info":""},{"id":"3c739ac.2ddd366","type":"inject","z":"2019e3ca.87d34c","name":"luce OFF","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":0,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":120,"wires":[["142125ce.f1cc3a"]]},{"id":"6e8e29a.faa99d8","type":"inject","z":"2019e3ca.87d34c","name":"luce ON","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":1,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":180,"wires":[["142125ce.f1cc3a"]]},{"id":"142125ce.f1cc3a","type":"switch","z":"2019e3ca.87d34c","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"MCPINT","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":140,"wires":[["7b3326f8.5483a8","3fc88044.4f7a78"],[]]},{"id":"7b3326f8.5483a8","type":"debug","z":"2019e3ca.87d34c","name":"switch MCP","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":60,"wires":[]},{"id":"7a721d7b.0371b4","type":"mqtt in","z":"2019e3ca.87d34c","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f0a64cae.6413e","x":110,"y":60,"wires":[[]]},{"id":"7b401d4f.46369c","type":"mqtt out","z":"2019e3ca.87d34c","name":"","topic":"","qos":"","retain":"","broker":"f0a64cae.6413e","x":610,"y":320,"wires":[]},{"id":"3fc88044.4f7a78","type":"change","z":"2019e3ca.87d34c","name":"JSONata","rules":[{"t":"set","p":"payload_end","pt":"msg","to":"payload.nvalue","tot":"jsonata"},{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/event\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"part3","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":140,"wires":[["32cceaba.1acb1e"]]},{"id":"32cceaba.1acb1e","type":"split","z":"2019e3ca.87d34c","name":"","splt":"payload=","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"exit","x":650,"y":140,"wires":[["14f7deac.c757b1"]]},{"id":"bf959fb9.d60908","type":"change","z":"2019e3ca.87d34c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":280,"wires":[["2095d260.787b0e","7b401d4f.46369c"]]},{"id":"14f7deac.c757b1","type":"switch","z":"2019e3ca.87d34c","name":"","property":"payload","propertyType":"jsonata","rules":[{"t":"cont","v":"cmnd","vt":"str"},{"t":"cont","v":"MCPINT","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":110,"y":320,"wires":[["bf959fb9.d60908"],["5e30d7ea.97b4d8"]]},{"id":"5e30d7ea.97b4d8","type":"change","z":"2019e3ca.87d34c","name":"","rules":[{"t":"set","p":"uno","pt":"msg","to":"msg.payload","tot":"jsonata"},{"t":"set","p":"due","pt":"msg","to":"msg.payload_end","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":380,"wires":[["13cbba17.7bd4be"]]},{"id":"13cbba17.7bd4be","type":"template","z":"2019e3ca.87d34c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{uno}}}{{due}}","output":"str","x":460,"y":380,"wires":[["b47806c4.7b80f8","7b401d4f.46369c"]]},{"id":"2095d260.787b0e","type":"debug","z":"2019e3ca.87d34c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":560,"y":240,"wires":[]},{"id":"b47806c4.7b80f8","type":"debug","z":"2019e3ca.87d34c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":420,"wires":[]},{"id":"f0a64cae.6413e","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.0.105","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 22:09 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/5 "2020-03-20T22:09:12Z")

</div>

Change your debug nodes to display 'Complete msg object' and see what shows up.

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 22:12 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/6 "2020-03-20T22:12:38Z")

</div>

> [@zenofmud](#):
>
> Change your debug nodes to display 'Complete msg object' and see what shows up.

```auto
20/3/2020, 23:10:06[node: e4577416.203558](http://192.168.0.105:1880/#)

cmnd/tasmota_mcp/event : msg : Object

{ topic: "cmnd/tasmota_mcp/event", payload_end: 1, part1: "topic=tasmota_mcp↵payload=MCPI…", part2: "topic=tasmota_mcp/eventpayload…", part3: "cmnd/tasmota_mcp/eventpayload=…" … }

20/3/2020, 23:10:06[node: e4577416.203558](http://192.168.0.105:1880/#)MCPINT_D0= : msg : Object

{ topic: "MCPINT_D0=", payload_end: 1, part1: "topic=tasmota_mcp↵payload=MCPI…", part2: "topic=tasmota_mcp/eventpayload…", part3: "cmnd/tasmota_mcp/eventpayload=…" … }

```

i do not undertand why if i use the complete msg object i have this output  
but if i look at msg.topic and msg.payload  
it seams that i have the output that i need

i change also a bit the flow but nothing change....i'm getting frustrated ☹

```auto
[{"id":"2019e3ca.87d34c","type":"tab","label":"luci_tasmota_mcp","disabled":false,"info":""},{"id":"3c739ac.2ddd366","type":"inject","z":"2019e3ca.87d34c","name":"luce OFF","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":0,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":120,"wires":[["142125ce.f1cc3a"]]},{"id":"6e8e29a.faa99d8","type":"inject","z":"2019e3ca.87d34c","name":"luce ON","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":1,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":180,"wires":[["142125ce.f1cc3a"]]},{"id":"142125ce.f1cc3a","type":"switch","z":"2019e3ca.87d34c","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"MCPINT","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":140,"wires":[["7b3326f8.5483a8","3fc88044.4f7a78"],[]]},{"id":"7b3326f8.5483a8","type":"debug","z":"2019e3ca.87d34c","name":"switch MCP","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":60,"wires":[]},{"id":"7a721d7b.0371b4","type":"mqtt in","z":"2019e3ca.87d34c","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f0a64cae.6413e","x":110,"y":60,"wires":[[]]},{"id":"7b401d4f.46369c","type":"mqtt out","z":"2019e3ca.87d34c","name":"","topic":"","qos":"","retain":"","broker":"f0a64cae.6413e","x":710,"y":300,"wires":[]},{"id":"3fc88044.4f7a78","type":"change","z":"2019e3ca.87d34c","name":"JSONata","rules":[{"t":"set","p":"payload_end","pt":"msg","to":"payload.nvalue","tot":"jsonata"},{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/event\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"part3","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":140,"wires":[["32cceaba.1acb1e"]]},{"id":"32cceaba.1acb1e","type":"split","z":"2019e3ca.87d34c","name":"","splt":"payload=","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"exit","x":650,"y":140,"wires":[["14f7deac.c757b1"]]},{"id":"14f7deac.c757b1","type":"switch","z":"2019e3ca.87d34c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"cmnd","vt":"str"},{"t":"cont","v":"MCPINT","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":110,"y":320,"wires":[["11b99d73.257573","e1b382bb.0e1558"],["5e30d7ea.97b4d8","977f056c.4b2768"]]},{"id":"5e30d7ea.97b4d8","type":"change","z":"2019e3ca.87d34c","name":"","rules":[{"t":"set","p":"uno","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"due","pt":"msg","to":"payload_end","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":380,"wires":[["13cbba17.7bd4be","d05c91a8.4818a8","f0ed70ca.f4748"]]},{"id":"13cbba17.7bd4be","type":"template","z":"2019e3ca.87d34c","name":"","field":"union","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{uno}}}{{due}}","output":"str","x":420,"y":380,"wires":[["b47806c4.7b80f8","e1b382bb.0e1558"]]},{"id":"2095d260.787b0e","type":"debug","z":"2019e3ca.87d34c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":560,"y":240,"wires":[]},{"id":"b47806c4.7b80f8","type":"debug","z":"2019e3ca.87d34c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"union","targetType":"msg","x":490,"y":460,"wires":[]},{"id":"e1b382bb.0e1558","type":"change","z":"2019e3ca.87d34c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"},{"t":"move","p":"union","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":300,"wires":[["825ef097.f90f2","e4577416.203558","2095d260.787b0e"]]},{"id":"825ef097.f90f2","type":"debug","z":"2019e3ca.87d34c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":660,"y":380,"wires":[]},{"id":"e4577416.203558","type":"debug","z":"2019e3ca.87d34c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":460,"wires":[]},{"id":"977f056c.4b2768","type":"debug","z":"2019e3ca.87d34c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":200,"y":540,"wires":[]},{"id":"11b99d73.257573","type":"debug","z":"2019e3ca.87d34c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":270,"y":280,"wires":[]},{"id":"d05c91a8.4818a8","type":"debug","z":"2019e3ca.87d34c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"uno","targetType":"msg","x":270,"y":460,"wires":[]},{"id":"f0ed70ca.f4748","type":"debug","z":"2019e3ca.87d34c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"due","targetType":"msg","x":270,"y":500,"wires":[]},{"id":"f0a64cae.6413e","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.0.105","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 22:17 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/7 "2020-03-20T22:17:33Z")

</div>

Well you have changed things in your current flow and it is NOT causing the `"Invalid topic specified"` error message anymore

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 22:24 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/8 "2020-03-20T22:24:12Z")

</div>

> [@zenofmud](#):
>
> Well you have changed things in your current flow and it is NOT causing the `"Invalid topic specified"` error message anymore

Yes, i try to change to solve the issue... But now i do not understand why i have this message when i use the debug with total message.  
If i look at msg.topic and msg.payload they seams to be ok.  
Why it generate a total mqtt message so wrong?!?  
Getting me crazy...  
I also do not know if there is an easy way to do this.. Maybe i complicated the flow

Also the description field can be filled using something different that can make easy the flow.  
I'm opening to every kind of suggestions.  
description fielled in the way that i showed is just my proposal to get the parameter of payload and topic that i need but i can change if it make easy the flow

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 22:34 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/9 "2020-03-20T22:34:22Z")

</div>

When you use a `debug` node, it defaults to displaying a portion of the entire msg, the payload part.  
When you use a `debug` node and tell it to display the 'Complete msg object' it is showing you the entire msg instead of just a part of it.

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 22:37 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/10 "2020-03-20T22:37:52Z")

</div>

Ok, but why the message generate is not the sum of topic + payload?  
If i debug only msg.topic and msg.paylod i have the correct value. Or i'm wrong?  
Thanks

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 23:03 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/11 "2020-03-20T23:03:11Z")

</div>

from the [documentation](https://nodered.org/docs/user-guide/concepts#message):

* * *

**Message**

Messages are what pass between the nodes in a flow. They are plain JavaScript objects that can have any set of properties. They are often referred to as `msg` within the editor.

By convention, they have a `payload` property containing the most useful information.

* * *

'topic' is another property. You can add properties to messages. If you use a `change` node and set 'msg.bannana' to a text string of 'apple' it will now be part of the msg for the rest of the flow (unless it is removed from the msg.you will see that)

I hope that clears things up. You should spend time reading about javaScript objects to get a handle on them.

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 23:17 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/12 "2020-03-20T23:17:23Z")

</div>

thanks for explanation.  
this is pretty much clear,but i'm still lost on where my messages didn't get the correct properties  
and i do not understand if the way that i'm using to manipulate them is correct or not  
thanks

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 23:32 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/13 "2020-03-20T23:32:44Z")

</div>

Let's go back to the beginning. You want to check the incoming msg for two things  
1 - if `msg.payload.desctiption` contains `MCPINT_D0=`  
and you are already doing that with your switch node. So only msgs that meet that condition get passed on. Next you want to chedk if `msg.payload.nvalue` is `1` or `0` - so use another switch node and test that out.

now you will have two branched flows - one for the `1` condition and one for the `0` condition. so, in each flow, build your response msg that you want to send and at the end connect both flows to the `MQTT-out` node and you should be done.

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [20 March 2020 23:50 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/14 "2020-03-20T23:50:43Z")

</div>

> [@zenofmud](#):
>
> Let's go back to the beginning. You want to check the incoming msg for two things  
> 1 - if `msg.payload.desctiption` contains `MCPINT_D0=`

no, i filter only with: `MCPINT`  
becuase the mqtt output that i can build can have for example:  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D0** = **0**  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D0** = **1**  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D3** = **0**  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D3** = **1**  
cmnd/ **light\_kitchen** /event MCPINT\_ **D4** = **1**  
cmnd/ **light\_kitchen** /event MCPINT\_ **D4** = **0**  
cmnd/ **bathroom\_2** /event MCPINT\_ **D6** = **0**  
cmnd/ **bathroom\_2** /event MCPINT\_ **D6** = **1**  
and so on....  
all words written in bold can change

for example we can consider:  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D0** = **1** (number after `=` can be `1` or `0` and this come from `nvalue`)  
as i wrote, words in bold can be different from a description field to another.  
these bold parameters are written inside description field and referring to the example the descriptio fileld will be:  
topic=`tasmota_mcp`  
payload=`MCPINT_D0=`  
or in a json format: `topic=tasmota_mcp\npayload=MCPINT_D0=`  
the number after `=` will taken from **nvalue** (that could be 1=on 0=off)

> [@zenofmud](#):
>
> and you are already doing that with your switch node. So only msgs that meet that condition get passed on. Next you want to chedk if `msg.payload.nvalue` is `1` or `0` - so use another switch node and test that out.

ok i have to record this parameter and save, because it will be placed after the `=` of `MCPINT_D0=`

> [@zenofmud](#):
>
> now you will have two branched flows - one for the `1` condition and one for the `0` condition. so, in each flow, build your response msg that you want to send and at the end connect both flows to the `MQTT-out` node and you should be done.

no, here come my main difficulties, i have to divide what i have inside description filed that is:  
`topic=tasmota_mcp\npayload=MCPINT_D0=`  
and i have to divide it to have a mqtt message that should be:  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D0** = **1**  
note the space between event and MCPINT  
`cmnd/tasmota_mcp/event` =\> topic  
`MCPINT_D0=1` =\> payload  
`1` after the `=` is coming from nvalue

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 March 2020 00:31 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/15 "2020-03-21T00:31:48Z")

</div>

So if I understand you, you will get a msg.payload like

```auto
{
  "Battery" : 255,
  "RSSI" : 12,
  "description" : "topic=tasmota_mcp\npayload=MCPINT_D0=",
  "dtype" : "Light/Switch",
  "hwid" : "6",
  "id" : "000140FE",
  "idx" : 174,
  "name" : "mcp_luce1",
  "nvalue" : 1,
  "stype" : "Switch",
  "svalue1" : "0",
  "switchType" : "On/Off",
  "unit" : 1
}

```

and the end result is to sent a response to the MQTT-out node with (in this case)  
msg.topic = `cmnd/tasmota_mcp/event`  
and  
msg.payload = `MCPINT_D0=1`

if the description was

```auto
{
  "Battery" : 255,
  "RSSI" : 12,
  "description" : "topic=light_kitchen\npayload=MCPINT_D4=",
  "dtype" : "Light/Switch",
  "hwid" : "6",
  "id" : "000140FE",
  "idx" : 174,
  "name" : "mcp_luce1",
  "nvalue" : 0,
  "stype" : "Switch",
  "svalue1" : "0",
  "switchType" : "On/Off",
  "unit" : 1
}

```

you would want  
msg.topic = `cmnd/light_kitchen/event`  
msg.payload = `MCPINT_D4=0`

Correct?

It would probably be esaiest to do this in a `function` node.

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [21 March 2020 00:43 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/16 "2020-03-21T00:43:43Z")

</div>

yes, you understand 100% correctly  
sorry if i made confusion on explain, but you understand correctly!  
please take into account that if you would like to change the sturcture of description field just to make the `function` that you propose more simple, i can change the description field writing the parameters needed in the way that you prefer

if using `function` become more simple, for example we can use inside description filed a json notation, example:  
{ "topic" : " light\_kitchen", "payload" : "MCPINT\_D4=" }

that will give as output:  
msg.topic = `cmnd/light_kitchen/event`  
msg.payload = `MCPINT_D4=0` (where the `0` after the `=` coming always from `nvalue` in the example below was `"nvalue" : 0`

so inside description filed we can write the data in the way that is more easy to manipulate

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 March 2020 08:16 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/17 "2020-03-21T08:16:26Z")

</div>

So do you control the topic and payload being sent to NR? If s, please put a debug node (set to display complete msg object) and run it.

In the debug sidebar, hover your mouse in the debug till you see this icon:  
 ![Screen Shot 2020-03-21 at 4.13.04 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bdf5734c98888f0331824810329bd74156579edf.png)  
clicking on it will copy the entire debug. Paste that here using the code `</>` button.

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [21 March 2020 12:01 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/18 "2020-03-21T12:01:23Z")

</div>

this is the dubg set as complete msg object that is put at the end of the flow.  
i receive:  
`{"topic":"cmnd/tasmota_mcp/event","payload_end":1,"part1":"topic=tasmota_mcp\npayload=MCPINT_D0=","part2":"topic=tasmota_mcp/eventpayload=MCPINT_D0=","part3":"cmnd/tasmota_mcp/eventpayload=MCPINT_D0=","parts":{"id":"94d4911b.ae57a","type":"string","ch":"payload=","index":0,"count":2},"_msgid":"93636837.391f28"}`  
and  
`{"topic":"MCPINT_D0=","payload_end":1,"part1":"topic=tasmota_mcp\npayload=MCPINT_D0=","part2":"topic=tasmota_mcp/eventpayload=MCPINT_D0=","part3":"cmnd/tasmota_mcp/eventpayload=MCPINT_D0=","parts":{"id":"94d4911b.ae57a","type":"string","ch":"payload=","index":1,"count":2},"_msgid":"1083342f.591abc","uno":"MCPINT_D0=","due":1,"payload":"MCPINT_D0=1"}`

this is one example of json injected, where, if you would like to implement a `function` node, i can write in a different way the `description` field to pass to NodeRed value in a different way that can make easy implement the `function`  
`{"Battery":255,"RSSI":12,"description":"topic=tasmota_mcp\npayload=MCPINT_D0=","dtype":"Light/Switch","hwid":"6","id":"000140FE","idx":174,"name":"mcp_luce1","nvalue":1,"stype":"Switch","svalue1":"0","switchType":"On/Off","unit":1}`

this is the flow with attached also the debug used and the injection flow on and off.  
i think that i make too much complicate the flow tring to manipulate the description filed...maybe i have to change the approach

```auto
[{"id":"e8abadf6.0af268","type":"tab","label":"luci_tasmota_mcp","disabled":false,"info":""},{"id":"1b72beb2.950b01","type":"inject","z":"e8abadf6.0af268","name":"luce OFF","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":0,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":120,"wires":[["7baccf6f.34fed"]]},{"id":"3001c820.f32988","type":"inject","z":"e8abadf6.0af268","name":"luce ON","topic":"","payload":"{\"Battery\":255,\"RSSI\":12,\"description\":\"topic=tasmota_mcp\\npayload=MCPINT_D0=\",\"dtype\":\"Light/Switch\",\"hwid\":\"6\",\"id\":\"000140FE\",\"idx\":174,\"name\":\"mcp_luce1\",\"nvalue\":1,\"stype\":\"Switch\",\"svalue1\":\"0\",\"switchType\":\"On/Off\",\"unit\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":180,"wires":[["7baccf6f.34fed"]]},{"id":"7baccf6f.34fed","type":"switch","z":"e8abadf6.0af268","name":"","property":"payload.description","propertyType":"msg","rules":[{"t":"cont","v":"MCPINT","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":140,"wires":[["3da211e6.294ff6","29bb36a7.aba402"],[]]},{"id":"3da211e6.294ff6","type":"debug","z":"e8abadf6.0af268","name":"switch MCP","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":60,"wires":[]},{"id":"88458d05.3bb168","type":"mqtt in","z":"e8abadf6.0af268","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f0a64cae.6413e","x":110,"y":60,"wires":[[]]},{"id":"354a9518.d5a8ba","type":"mqtt out","z":"e8abadf6.0af268","name":"","topic":"","qos":"","retain":"","broker":"f0a64cae.6413e","x":710,"y":300,"wires":[]},{"id":"29bb36a7.aba402","type":"change","z":"e8abadf6.0af268","name":"JSONata","rules":[{"t":"set","p":"payload_end","pt":"msg","to":"payload.nvalue","tot":"jsonata"},{"t":"set","p":"part1","pt":"msg","to":"payload.description","tot":"jsonata"},{"t":"set","p":"part2","pt":"msg","to":"$replace(part1,\"\\n\", \"/event\")","tot":"jsonata"},{"t":"set","p":"part3","pt":"msg","to":"$replace(part2,\"topic=\", \"cmnd/\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"part3","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":140,"wires":[["6ea782cb.746b34"]]},{"id":"6ea782cb.746b34","type":"split","z":"e8abadf6.0af268","name":"","splt":"payload=","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"exit","x":650,"y":140,"wires":[["cfc59d08.02d298"]]},{"id":"cfc59d08.02d298","type":"switch","z":"e8abadf6.0af268","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"cmnd","vt":"str"},{"t":"cont","v":"MCPINT","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":110,"y":320,"wires":[["499bd46e.8e3a44","3e4b7dfc.22e642"],["d89ddbfc.35c1e8","b7699cec.cdf1d"]]},{"id":"d89ddbfc.35c1e8","type":"change","z":"e8abadf6.0af268","name":"","rules":[{"t":"set","p":"uno","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"due","pt":"msg","to":"payload_end","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":380,"wires":[["133b3620.a1ded2","cf87192.6628e68","7c88c9e1.69df08"]]},{"id":"133b3620.a1ded2","type":"template","z":"e8abadf6.0af268","name":"","field":"union","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{uno}}}{{due}}","output":"str","x":420,"y":380,"wires":[["12320b06.6152bd","3e4b7dfc.22e642"]]},{"id":"3608b2c4.c9ec26","type":"debug","z":"e8abadf6.0af268","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":560,"y":240,"wires":[]},{"id":"12320b06.6152bd","type":"debug","z":"e8abadf6.0af268","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"union","targetType":"msg","x":490,"y":460,"wires":[]},{"id":"3e4b7dfc.22e642","type":"change","z":"e8abadf6.0af268","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"},{"t":"move","p":"union","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":300,"wires":[["a8394405.0d81e8","5ece7020.f7f9c","3608b2c4.c9ec26"]]},{"id":"a8394405.0d81e8","type":"debug","z":"e8abadf6.0af268","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":660,"y":380,"wires":[]},{"id":"5ece7020.f7f9c","type":"debug","z":"e8abadf6.0af268","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":460,"wires":[]},{"id":"b7699cec.cdf1d","type":"debug","z":"e8abadf6.0af268","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":200,"y":540,"wires":[]},{"id":"499bd46e.8e3a44","type":"debug","z":"e8abadf6.0af268","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":270,"y":280,"wires":[]},{"id":"cf87192.6628e68","type":"debug","z":"e8abadf6.0af268","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"uno","targetType":"msg","x":270,"y":460,"wires":[]},{"id":"7c88c9e1.69df08","type":"debug","z":"e8abadf6.0af268","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"due","targetType":"msg","x":270,"y":500,"wires":[]},{"id":"f0a64cae.6413e","type":"mqtt-broker","z":"","name":"mosquitto","broker":"192.168.0.105","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 March 2020 12:23 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/19 "2020-03-21T12:23:21Z")

</div>

What/how are you creating the topic of the incoming message?  
Can you control how the topic is created?

---

<div class="post-metadata">

**Author:** ![megamarco83](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@megamarco83](https://discourse.nodered.org/u/megamarco83)\
**Post date:** [21 March 2020 12:50 UTC](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363/20 "2020-03-21T12:50:16Z")

</div>

sorry, not sure that i understand well you question.  
the description field is coming from devices on domoticz.  
when i press the device on domoticz, it send out using mqtt a json. inside this json there is also the description field.  
the description field can be manage by me inside domoticz writing what i want.  
so, my idea, was to put inside this field some informations usefull to build the output command with nodered that should manipulate description field received to buld the output command to tasmota device in the way that explained:

for example:  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D0** = **0**  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D0** = **1**  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D3** = **0**  
cmnd/ **tasmota\_mcp** /event MCPINT\_ **D3** = **1**  
cmnd/ **light\_kitchen** /event MCPINT\_ **D4** = **1**  
cmnd/ **light\_kitchen** /event MCPINT\_ **D4** = **0**  
cmnd/ **bathroom\_2** /event MCPINT\_ **D6** = **0**  
cmnd/ **bathroom\_2** /event MCPINT\_ **D6** = **1**  
and so on....  
all words written in bold can change

starting from a domoticz json received by nodered, i should use nodered to elaborate the description field received and create the example of commands above

i don't know if i answered at your question.

[Next page](https://discourse.nodered.org/t/from-a-mqtt-message-extract-and-modify-two-parameters-to-create-a-new-one/23363.md?page=2)
