For instance the msg.payload
is this:
DayEnd,33,128,99
I want to derive 4 variables:
time
, r
, g
and b
to use in the same node to do things.
For instance the msg.payload
is this:
DayEnd,33,128,99
I want to derive 4 variables:
time
, r
, g
and b
to use in the same node to do things.
Unless i am misunderstanding:
let input = msg.payload.split(",") // DayEnd,33,128,99
let time = input[0]
let r = input[1]
let g = input[2]
let b = input[3]
Thanks.
I just found that command and was in the process of testing it.
You posting it is good to see.
The die-hards would use const
s instead of let
s, but you get the gist
FYI, you can also assign the list of split parts to multiple vars like so:
let [time, r, g, b] = msg.payload.split(",");
Btw, if the split only returned 3 parts, the 4th variable would have the value undefined
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.