Change Payload Value in Text

Hello,

i have noting find in the search.
is it possible to change the Payload Value 1 and 0 in a text for sending?

in attachment a picture from my test, but the sending is only 0 or 1 i don`t can change the value.

Thank you
Stefan

Welcome.

sorry could not understand the requirement, but see if this is what you expected.

[{"id":"59d9020ac04ecaba","type":"inject","z":"53edcbb0228e136a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"This is a payload containing 0 and 1","payloadType":"str","x":590,"y":3540,"wires":[["689cb6fcabaa3307","d18685ac97441002"]]},{"id":"1ca1175f85b08435","type":"debug","z":"53edcbb0228e136a","name":"debug 2507","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":3540,"wires":[]},{"id":"689cb6fcabaa3307","type":"change","z":"53edcbb0228e136a","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"str","to":"(this was zero)","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"str","to":"(this was one)","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":3540,"wires":[["1ca1175f85b08435"]]},{"id":"d18685ac97441002","type":"debug","z":"53edcbb0228e136a","name":"debug 2508","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":3470,"wires":[]}]

I'll try again. In the said payload, the open state 0 closed and 1 open of a door sensor is delivered. But I want to convert the value 0 or 1 into a string and then send it as a message
0 should be changed to "door closed"
1 should be changed to “Door opened”

I hope the description is now clearer?

Thanks for your help.

This will look for "0" and replace with "door closed"

[{"id":"8a510de3a49fa2b4","type":"inject","z":"53edcbb0228e136a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":510,"y":3640,"wires":[["a2bdf0700c85f27a"]]},{"id":"a2bdf0700c85f27a","type":"switch","z":"53edcbb0228e136a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":3660,"wires":[["30f5ea8ca1724766"],["519a67a4268810d1"]]},{"id":"63eed357b8ebfdc5","type":"inject","z":"53edcbb0228e136a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":510,"y":3690,"wires":[["a2bdf0700c85f27a"]]},{"id":"30f5ea8ca1724766","type":"change","z":"53edcbb0228e136a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"The Door is Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":3630,"wires":[["5cb68d24453f2a05"]]},{"id":"519a67a4268810d1","type":"change","z":"53edcbb0228e136a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"The Door is Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":3680,"wires":[["5cb68d24453f2a05"]]},{"id":"5cb68d24453f2a05","type":"debug","z":"53edcbb0228e136a","name":"debug 2509","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1070,"y":3660,"wires":[]}]

0and1

assuming the payload is equal to 0 or 1

If it contains 0 and 1 , then @cymplecy solution should work.

unfortunately this doesn't work:
v3/doorsens@ttn/devices/chicken-out/up : msg.payload : number 1
is the payload result.
and if I change that to open door

image

it will still be passed as 1

image

thanks i will check with a switch befor

perfect, it works, thank you.

I had two mistakes.
The payload was queried once not as a payload but again as a payload status.
and then didn't use the switch.
Both combinations work together and the text is transmitted.

Many thanks

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