Node-red-node-pi-sense-hat - can't get multiple commands to work

#1

Node-RED version: v0.18.7
Node.js version: v8.11.2
node-red-node-pi-sense-hat@0.0.15

Playing with the RPI Sense Hat and I can not get multiple commands to work in a single msg.payload.
If I send one msg.payload with:
R
and a second with
0,0,red,0,7,#00ff00,7,7,yellow,7,0,0,0,255
I get the letter ‘R’ and each of the four corners is colored.

If I send one msg.payload with:
R\n0,0,red,0,7,#00ff00,7,7,yellow,7,0,0,0,255
which should do the same thing, instead you see the entire line scrolled across the display.

Here is a flow showing the issue:
[{"id":"caa66d9d.b7aed8","type":"inject","z":"c3525ae7.a368a8","name":"2) color the corners","topic":"","payload":"0,0,red,0,7,#00ff00,7,7,yellow,7,0,0,0,255","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":140,"wires":[["5c1e5753.660f78"]]},{"id":"f5761e7.f3c03e","type":"inject","z":"c3525ae7.a368a8","name":"display an R and color the corners","topic":"","payload":"R\\n0,0,red,0,7,#00ff00,7,7,yellow,7,0,0,0,255","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":240,"wires":[["da53dcd.f9aa2a"]]},{"id":"da53dcd.f9aa2a","type":"rpi-sensehat out","z":"c3525ae7.a368a8","name":"","x":470,"y":240,"wires":[]},{"id":"e9664a98.d0b4c8","type":"inject","z":"c3525ae7.a368a8","name":"1) display the character 'R'","topic":"","payload":"R","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":100,"wires":[["5c1e5753.660f78"]]},{"id":"9d757ff4.713ec","type":"comment","z":"c3525ae7.a368a8","name":"If you display a single letter and then color the corners it works/","info":"","x":290,"y":60,"wires":[]},{"id":"2941dc48.9acb5c","type":"comment","z":"c3525ae7.a368a8","name":"Combining the two does not work.","info":"","x":180,"y":200,"wires":[]},{"id":"5c1e5753.660f78","type":"rpi-sensehat out","z":"c3525ae7.a368a8","name":"","x":470,"y":120,"wires":[]}]

#5

How are you including the \n in the string? If it is by the Inject node or Change node, for example, then they don’t know about escaped strings and will include a literal \n not a new-line character.

Try using a Function node to generate the payload with the \n in and you should see it work.

#7

Ahhh I just saw this at the end of the inject node’s 'Node Help:

Note: To include a newline in a string you must use a Function node to create the payload.

I’ll add this tidbit to the DOCUP thread and create a PR for it.