Hi.
I have this flow, that control a folder in my mail, and if there is a mail it grab the image and send it by telegram, and then delete the message.
My problem is, that I get two telegram messages, with the same image of all mails in the folder.
So every mail, is send by telegram two times before going to the next mail.
How can I edit the flow, so I only will get one telegram message, when getting a mail?
[
{
"id": "c0a3796d552b0784",
"type": "comment",
"z": "b76b4fef47b27005",
"name": "Telegram besked, ved Motion Detection!",
"info": "Benytter:\nnode-red-contrib-watchdirectory\nnode-red-contrib-telegrambot\n###############################\n1 x Watch-directory node (Watchdirectory)\n1 x Switch node (NR)\n1 x Function node (NR)\n1 x Delay node (NR)\n1 x Sender node (Telegram)\n3 x Debug node (NR)",
"x": 170,
"y": 460,
"wires": []
},
{
"id": "7e395e24d3d47c87",
"type": "inject",
"z": "b76b4fef47b27005",
"name": "Search every 5. sec",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "deletepath",
"v": "\\NVR",
"vt": "str"
}
],
"repeat": "10",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 540,
"wires": [
[
"a258fa9580855fe3"
]
]
},
{
"id": "fbbd4cae89642a30",
"type": "debug",
"z": "b76b4fef47b27005",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "topic",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 980,
"y": 620,
"wires": []
},
{
"id": "152df24f339b5417",
"type": "split",
"z": "b76b4fef47b27005",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 810,
"y": 540,
"wires": [
[
"d6429274201ec237"
]
]
},
{
"id": "52ed7dd302baaf28",
"type": "change",
"z": "b76b4fef47b27005",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "attachments",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 540,
"wires": [
[
"152df24f339b5417"
]
]
},
{
"id": "2a8cc13f57e5f3c3",
"type": "telegram sender",
"z": "b76b4fef47b27005",
"name": "",
"bot": "",
"haserroroutput": false,
"outputs": 1,
"x": 410,
"y": 640,
"wires": [
[
"9202bd61346071f2"
]
]
},
{
"id": "d6429274201ec237",
"type": "change",
"z": "b76b4fef47b27005",
"name": "compose filename and load content to payload",
"rules": [
{
"t": "set",
"p": "filename",
"pt": "msg",
"to": "\"/NVR/snap\" & $millis() & \".jpg\"",
"tot": "jsonata"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.content",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1080,
"y": 540,
"wires": [
[
"26ac0911f6568cd9",
"fbbd4cae89642a30",
"715a7f87f2c0a4d3"
]
]
},
{
"id": "26ac0911f6568cd9",
"type": "file",
"z": "b76b4fef47b27005",
"name": "Save picture to disk",
"filename": "filename",
"filenameType": "msg",
"appendNewline": true,
"createDir": true,
"overwriteFile": "true",
"encoding": "none",
"x": 1070,
"y": 480,
"wires": [
[]
]
},
{
"id": "715a7f87f2c0a4d3",
"type": "function",
"z": "b76b4fef47b27005",
"name": "Set topic and filename",
"func": "var payload = { \n chatId: -xxxxxxxxxxxxxxxx,\n type: \"photo\",\n content: msg.payload,\n caption: msg.topic + \"\\r\\nMotion detection fanget én eller flere personer\"};\n \nreturn {payload};",
"outputs": 1,
"noerr": 1,
"initialize": "",
"finalize": "",
"libs": [],
"x": 180,
"y": 640,
"wires": [
[
"2a8cc13f57e5f3c3"
]
]
},
{
"id": "24d2922b1166c40e",
"type": "comment",
"z": "b76b4fef47b27005",
"name": "Hent mail hver 5. sek., gem billede og slet mail!",
"info": "Benytter:\nnode-red-contrib-watchdirectory\nnode-red-contrib-telegrambot\n###############################\n1 x Watch-directory node (Watchdirectory)\n1 x Switch node (NR)\n1 x Function node (NR)\n1 x Delay node (NR)\n1 x Sender node (Telegram)\n3 x Debug node (NR)",
"x": 240,
"y": 500,
"wires": []
},
{
"id": "23a9fc0a8bcf51b4",
"type": "comment",
"z": "b76b4fef47b27005",
"name": "Send billede til Telegram, slet billede igen!",
"info": "Benytter:\nnode-red-contrib-watchdirectory\nnode-red-contrib-telegrambot\n###############################\n1 x Watch-directory node (Watchdirectory)\n1 x Switch node (NR)\n1 x Function node (NR)\n1 x Delay node (NR)\n1 x Sender node (Telegram)\n3 x Debug node (NR)",
"x": 220,
"y": 600,
"wires": []
},
{
"id": "09f240891eecfc06",
"type": "inject",
"z": "b76b4fef47b27005",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 510,
"y": 480,
"wires": [
[
"a258fa9580855fe3"
]
]
},
{
"id": "f550e83400270695",
"type": "debug",
"z": "b76b4fef47b27005",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 760,
"y": 480,
"wires": []
},
{
"id": "a258fa9580855fe3",
"type": "e-mail in",
"z": "b76b4fef47b27005",
"name": "Simply GET-Mail",
"protocol": "IMAP",
"server": "mail.simply.com",
"useSSL": true,
"autotls": "always",
"port": "993",
"box": "NVR",
"disposition": "Delete",
"criteria": "ALL",
"repeat": "5",
"fetch": "trigger",
"inputs": 1,
"x": 400,
"y": 540,
"wires": [
[
"f550e83400270695",
"52ed7dd302baaf28"
]
]
},
{
"id": "9202bd61346071f2",
"type": "debug",
"z": "b76b4fef47b27005",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "topic",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 620,
"y": 620,
"wires": []
}
]