How change a text except the variable numbers from a payload

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 :slight_smile:


[{"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"}]

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.

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

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.

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

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.

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.

use a change node set to move

1 Like

If you don't know how to do that then read the node red docs page Working with 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.

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.
:+1:

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