shel
22 February 2023 19:16
1
I get some data from a sensor that looks like
I assume the little arrow in the front of the text must be some kind of carriage return? I haven't figured out how to strip that from the payload. That character is always the first but the length of the payload varies
thanks
edje11
22 February 2023 19:33
2
You can do in a function node
msg.payload = msg.payload.substring(1)
return msg;
This will return the string minus the first character.
shel
22 February 2023 19:37
3
sorry but the funky character still shows up when I use that in a function
E1cid
22 February 2023 19:45
4
To remove any whitespace before and after, in a function node use.
msg.payload = msg.payload.trim()
return msg;
Or in a chnage node and JSONata
use
$trim($$.payload)
And there is also the contrib string node.
EDIT by @Paul-Reed - correct typo
shel
22 February 2023 19:48
5
that's the ticket !!
thanks
Colin
22 February 2023 20:07
6
If what you actually want is the number, then you can use
msg.payload = Number(msg.payload)
system
Closed
8 March 2023 20:08
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.