If and return messages from mqtt

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

I edited your post to fix it.

In a function node you could do something like this:

if (msg.payload == 'Liga') {
    msg.payload = true;
}
if (msg.payload == 'Desliga') {
    msg.payload = 1;
}

return msg;

I'm unsure if you want the scond one to be a 1 or 0

1 Like