Thanks to the awesome work by @Steve-Mcl I've managed to get my Telegram alerts running. Thanks Steve.
I am now attempting to add email alerting to the same flow... only, I cannot get the Subject to work? Node Red seems to be happy with the flow, but only shows the code in the subject and not the value?
Here's my code...
[
{
"id": "c18d9ee81483eb22",
"type": "debug",
"z": "fda74e4b5bc38453",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 870,
"y": 320,
"wires": []
},
{
"id": "d7bc597446137a4e",
"type": "inject",
"z": "fda74e4b5bc38453",
"name": "*** Setup devices to ping here ***",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[{\"name\":\"gateway\",\"host\":\"192.168.4.5\"},{\"name\":\"Server 2\",\"host\":\"192.168.4.7\"},{\"name\":\"Server 1\",\"host\":\"192.168.4.29\"},{\"name\":\"Server 3\",\"host\":\"192.168.4.9\"},{\"name\":\"Server 5\",\"host\":\"192.168.4.14\"}]",
"payloadType": "json",
"x": 490,
"y": 320,
"wires": [
[
"88ed34f6f40208e6"
]
]
},
{
"id": "88ed34f6f40208e6",
"type": "ping",
"z": "fda74e4b5bc38453",
"mode": "triggered",
"name": "",
"host": "",
"timer": "20",
"inputs": 1,
"x": 710,
"y": 320,
"wires": [
[
"c18d9ee81483eb22",
"ec850e934b4a3560"
]
]
},
{
"id": "ec850e934b4a3560",
"type": "function",
"z": "fda74e4b5bc38453",
"name": "Prepare telegram message (if bad)",
"func": "if(msg.payload === false) {\n msg.payload = {};\n msg.payload.type = 'message';\n msg.payload.content = `Ping to '${msg.ping.name}' (${msg.ping.host}) failed`;\n msg.payload.chatId = 5612125043\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 400,
"wires": [
[
"2146c727b359180b",
"dbd882ec3cc0864e"
]
]
},
{
"id": "305bafda3cfebc5c",
"type": "debug",
"z": "fda74e4b5bc38453",
"name": "to Email node",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 940,
"y": 400,
"wires": []
},
{
"id": "2146c727b359180b",
"type": "function",
"z": "fda74e4b5bc38453",
"name": "Server Down Email",
"func": "msg.payload.content = `Ping to '${msg.ping.name}' (${msg.ping.host}) failed`;\nmsg.payload.topic = 'WARNING!! ${msg.ping.name} Server DOWN';\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 400,
"wires": [
[
"305bafda3cfebc5c"
]
]
},
{
"id": "dbd882ec3cc0864e",
"type": "debug",
"z": "fda74e4b5bc38453",
"name": "to Telegram node",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 950,
"y": 460,
"wires": []
}
]
I also want to add a time stamp to the email... I usually use +time but not sure where to add it?
Appreciate any advice. Thanks, Mark