hi i know its going to be something simple what i what is to help me with:
i want to convert the number 1-255 that comes from a dashboard slider to 0:number for exmle 0:255 and then send it via mqtt ?
how is that possible ?
thanks in advance
chris giaitzoglou
You could use a change node with a jsonata expression
or a change node with a cuple rules to set x = '0:qaz then replace qaz with msg.payload then move x to msg.payload
or a function node
wow i never would have through to use a change node like this ever! but it makes really sense the logic thanks for that you help a lot also to think differently .
As you may have guess i am newbie i also just starting to learn java script , itried a function node where i had something like this
var msg=msg.payload
var newMsg= 0;
var newMsg1=":"
return [newMsg,newMsg1,msg]
but it diidnt work (in my head the logic was good but it got me to an error)
thanks again for your help
There are probably a dozen ways to concatenate your incoming payload with another string -- besides those already suggested, I think the simplest is the template node. You can use the following "mustache" syntax to get the output you want:
Note that the msg. prefix is not used inside the variable substitution braces, e.g. {{ payload }}, since all the named fields are expected to come from the incoming msg object.