# How change a text except the variable numbers from a payload

**URL:** <https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751>\
**Category:** General\
**Created:** [24 October 2020 15:44 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751 "2020-10-24T15:44:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![freak23](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@freak23](https://discourse.nodered.org/u/freak23)\
**Post date:** [24 October 2020 15:44 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/1 "2020-10-24T15:44:12Z")

</div>

Hello together,

I‘m facing a problem on how to change a text from a variable number coming from a payload string into another named payload string. I want to use a dimmable switch for jalousie control. Therefore it will be necessary to change the text in the payload string. Is this possible with the change node or will a function node do this better?  
Any help is appreciated 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/37bcd05edfa47023977b3e26238ad5da38f221e2.jpeg) ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/36dc5287cf66920d92ed38df1a7bd190907ef933.jpeg)

```auto

[{"id":"27123327.7d6274","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"3ba3931b.aed27c","type":"vsh-virtual-device","z":"27123327.7d6274","name":"Jalousie","connection":"5c8311f1.41d958","template":"DIMMER_SWITCH","passthrough":false,"x":80,"y":160,"wires":[["24553c10.7a3b34"]]},{"id":"24553c10.7a3b34","type":"json","z":"27123327.7d6274","name":"","property":"payload","action":"","pretty":false,"x":250,"y":160,"wires":[["e174b669.2e4e"]]},{"id":"e174b669.2e4e","type":"debug","z":"27123327.7d6274","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":160,"wires":[]},{"id":"5c8311f1.41d958","type":"vsh-connection","name":"Alexa","port":"8883","accessTokenExpiry":"1603310276762"}]

```

---

<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:** [24 October 2020 16:04 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/2 "2020-10-24T16:04:37Z")

</div>

Start by taking out the JSON node that is (apparently) converting the javascript object into a JSON string. Then post what you see coming in.

Next tell use _exactly_ what you want to see in the message you want to pass on.

---

<div class="post-metadata">

**Author:** ![freak23](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@freak23](https://discourse.nodered.org/u/freak23)\
**Post date:** [24 October 2020 16:20 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/3 "2020-10-24T16:20:19Z")

</div>

Hi Colin,

Here is what I want to do:  
The payload coming from my Alexa dimmer switch contains a number from 0 till 100 depending on the selection at the app.

Now I want to use the numbers coming from the dimmer switch and change the text to be able to use with the roller switch. The roller switch works with the following payload:

`shellies/shellyswitch25-<deviceid>/roller/0/command/pos` accepts a number between 0 and 100, which is the target position in percent

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b6fd5f9133bbcb4333cd5a343c1efd9a75a839b1.jpeg)

---

<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:** [24 October 2020 16:24 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/4 "2020-10-24T16:24:09Z")

</div>

So for the example you show with brightness 72 what message do you want to generate that will control the shelly? It is not good just saying it is different, we need to know what it is to tell you how to achieve it.

---

<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 October 2020 16:26 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/5 "2020-10-24T16:26:21Z")

</div>

In the http request node use the mustache template i.e.

```auto
http://ip/shellies/shellyswitch25-<deviceid>/roller/0/command/pos/{{payload.brightness}}

```

Edit/ did not see the mqtt in the image till just now. so you would need to move msg,payload.brightness to msg.payload, and use the path as the topic.

---

<div class="post-metadata">

**Author:** ![freak23](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@freak23](https://discourse.nodered.org/u/freak23)\
**Post date:** [24 October 2020 16:38 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/6 "2020-10-24T16:38:10Z")

</div>

Exactly, I need to send the payload to the roller shutter via MQTT.  
The Shelly 2.5 I‘m using gets the command via MQTT message.

---

<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 October 2020 16:39 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/7 "2020-10-24T16:39:35Z")

</div>

use a change node set to move

---

<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:** [24 October 2020 19:43 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/8 "2020-10-24T19:43:08Z")

</div>

If you don't know how to do that then read the node red docs page [Working with Messages](https://nodered.org/docs/user-guide/messages), or watch the linked videos if that is your preference. Also probably worth watching all the other Node Red Essentials videos, you will learn a lot.

---

<div class="post-metadata">

**Author:** ![freak23](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@freak23](https://discourse.nodered.org/u/freak23)\
**Post date:** [24 October 2020 20:01 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/9 "2020-10-24T20:01:54Z")

</div>

Thank you guys for the quick and very helpful answers.  
I just tried it with the change and move node and it works perfectly!  
Sometimes the solution is easier than expected.  
👍

---

<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:** [7 November 2020 20:02 UTC](https://discourse.nodered.org/t/how-change-a-text-except-the-variable-numbers-from-a-payload/34751/10 "2020-11-07T20:02:02Z")

</div>

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