Node red switch

Hello,

Can someone please help me.

I would like to create a switch with true and false.

It should be true if the msg.payload = "PUT operation successful."

He should be bad if:
"msg.error time out"

Reason:
If the transfer was successful, I would like to delete the file.
If the transfer has an error, do not delete the file.

Thank you.

Send File okay:

14.1.2024, 18:16:56node: debug 19
msg : Object
object
_msgid: "eaf5ba0bbbfbe523"
host: "192.xxx.xxx.xxx"
port: "xxxx"
user: "xxxx"
password: "xxxx"
operation: "PUT"
filename: "Sonde 1.csv"
localFilename: "/xxxxxx/www/xxxx/Sonde 1.csv"
payload: "PUT operation successful."

Send File error:

14.1.2024, 18:17:12node: 7e1f5df1188d0149
msg : error
"Error: Timeout while connecting to server"

Image Error:
node red 1

Image Okay:
node red 2

What do you want to happen if you get a result from the ftp node, but it is not "PUT operation successful".

You would use a catch node to catch the error message, select the ftp node in the catch node config. A simple switch node with rule == to direct the success, you can also use otherwise in the switch node rules to direct any other response.

Example

[{"id":"5594c86bcd8f5e6d","type":"inject","z":"d1395164b4eec73e","name":"put","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"PUT Operation successful","payloadType":"str","x":170,"y":3100,"wires":[["90f398c848510ac6"]]},{"id":"90f398c848510ac6","type":"switch","z":"d1395164b4eec73e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"PUT operation successful","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":3100,"wires":[["ad128ba84e8ec9ae"],["8f5a15c392e69325"]]},{"id":"e9d94eff8ad3dc28","type":"inject","z":"d1395164b4eec73e","name":"error","props":[{"p":"error","v":"Timeout","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":3160,"wires":[["90f398c848510ac6"]]},{"id":"ad128ba84e8ec9ae","type":"debug","z":"d1395164b4eec73e","name":"success","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":460,"y":3080,"wires":[]},{"id":"8f5a15c392e69325","type":"debug","z":"d1395164b4eec73e","name":"error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":3120,"wires":[]}]

node red 3
node red 4

:woozy_face:

I would like to delete the Local file if the transfer was successful.

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