Scan code automatization

Export your flow and paste it in a reply (don't forget backticks)

[{"id":"5a7ef36c.a575bc","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"cf7f4827.e63978","type":"e-mail in","z":"5a7ef36c.a575bc","name":"","protocol":"IMAP","server":"imap.gmail.com","useSSL":true,"port":"993","box":"INBOX","disposition":"Read","criteria":"ALL","repeat":"6","fetch":"auto","inputs":0,"x":410,"y":500,"wires":[["91b2e64c.c25da8"]]},{"id":"941feb52.2af968","type":"function","z":"5a7ef36c.a575bc","name":"","func":"\nif(msg.payload.x === msg.payload.y){\n    msg.payload=\"RIGHT\";\n}else{\n    msg.payload=\"WRONG\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":970,"y":380,"wires":[["b34b3483.4402c8"]]},{"id":"91b2e64c.c25da8","type":"join","z":"5a7ef36c.a575bc","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":750,"y":420,"wires":[["85823265.ba4ab","941feb52.2af968"]]},{"id":"85823265.ba4ab","type":"debug","z":"5a7ef36c.a575bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1030,"y":600,"wires":[]},{"id":"2ba4d3ea.56f3fc","type":"inject","z":"5a7ef36c.a575bc","name":"","topic":"x","payload":"10987654321","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":340,"wires":[["91b2e64c.c25da8"]]},{"id":"b34b3483.4402c8","type":"debug","z":"5a7ef36c.a575bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1190,"y":440,"wires":[]}]

8


if i use a normal input string it works

In situations where you are unsure what is going on, it always helps to fake the data.

As i dont have your Emails - i am faking the data here...

Here is the flow...

[{"id":"ee6feeca.2b3ae","type":"function","z":"75a7c9c2.729228","name":"","func":"\nif(msg.payload.x === msg.payload.y){\n    msg.payload=\"RIGHT\";\n}else{\n    msg.payload=\"WRONG\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":280,"wires":[["c458cb3b.3e6348"]]},{"id":"2420dc69.f2f964","type":"join","z":"75a7c9c2.729228","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":280,"wires":[["5bd0f723.e37058","ee6feeca.2b3ae"]]},{"id":"5bd0f723.e37058","type":"debug","z":"75a7c9c2.729228","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":690,"y":340,"wires":[]},{"id":"2094efc.f0ab61","type":"inject","z":"75a7c9c2.729228","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"x","payload":"123456789","payloadType":"str","x":310,"y":180,"wires":[["2420dc69.f2f964"]]},{"id":"c458cb3b.3e6348","type":"debug","z":"75a7c9c2.729228","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":830,"y":280,"wires":[]},{"id":"269f3a72.035b96","type":"inject","z":"75a7c9c2.729228","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"y","payload":"123456789","payloadType":"str","x":310,"y":340,"wires":[["2420dc69.f2f964"]]},{"id":"24cc5e8e.7c8962","type":"inject","z":"75a7c9c2.729228","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"y","payload":"987654321","payloadType":"str","x":310,"y":380,"wires":[["2420dc69.f2f964"]]},{"id":"fe06ad3e.d0a15","type":"inject","z":"75a7c9c2.729228","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"x","payload":"987654321","payloadType":"str","x":310,"y":220,"wires":[["2420dc69.f2f964"]]}]


i try to store the email data into a file .log and then compare that file to the input but it says to me WRONG how can i resolve that?

A single line string will NEVER equal multi-line string

What do you expect to happen?

Are you looking for msg.payload.x inside? on one line? in a loop?

Please explain your logic

i know that one single line string isn't equal multi-line string, i want to know if it's possible to look inside the file .log and see if the input msg.payload.x(10987654321) is inside. then if it's inside "RIGHT" else "WRONG".

But you didnt say that.

You said

Also, your terminology is incorrect, node-red doesnt "look inside" a file - you load the file and scan its content.

you could use the JS string includes function

if(msg.payload.y.includes(msg.payload.x)){
//found it
} else {
//not found
}

NOTE: If you are want to be proficient in node-red then you really should do some JavaScript training Nothing too heavy - something online - or YouTube JavaScript for beginners.

13
now my flow look like this. if the msg.payload.y contains msg.payload.y then light the led 1 else light the led 2, how can i insert a button that reset the if in short word switch off the led?

I don't see the reasoning behind a manual comparison function when a switch node does the same thing.

Your question doesn't make a lot of sense. do you want to turn off the opposite pin?

If so, then instead of return [msg,null], return [msg,{payload:false}]

That will send a false value to the 2nd output of the function to turn off the opposite pin.

Do the reverse for the 2nd return

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.