I'm sorry if the question is redundent, but I've been through the forum and still can't quite get my function working.
I have the following Pixel Code examples #1 and# 2 which are working independently of each other, and as expected. The output flows into a .py text file and works fine.
Pixel Code #1:
if ( fruit =='apples' ) {msg.payload = 'pixels[19]=(255,255,255) ' } else...
Here's the trouble...
I would like to combine multiple if's with multiple outputs into one statement. Something like the example below, but I can't get the syntax of the outputs correct.
Overall, the code works well when I want to test for one condition and one output (light up one led), but now I'm trying to test for two conditions and have two outputs (light up two seperate leds).
pixels[19]=(255,0,0) is wrapped in single quotes 'pixels[19]=(255,0,0)' but pixels[20]=(255,0,0) is not. I was not sure if it was a coding error or an error copying the code to here.
I asked if you are processing a single message or multiple ones because it's a common (beginners) error to think you can combine data from two different payloads in the same function code. But you are not in this situation so all is good.
I asked if you are using the Write File node beause it has the ability to append a new line after each message output. That means you could send the pixels[19] and pixels[20] individually with node.send(). It's not necessary though because you can use @E1cid's code to send them as one.
I presume you have confirmed that the python file with both lines in does light both LEDs.
After reading the replies and making the suggested changes to the function, it all is working as it should. Pairs of LED's are lighting up when both conditions are met. I'm posting the solution here for others who may have a similar issue.