Hello nice Node-RED people, I come to you for help.
I want to send an email to notify me when Frigate detects a person. Frigate is configured to use MQTT, and the image data arrives in an MQTT message.
At first I tried to use the data that is sent in msg.payload directly, as described in the email node Help.
I got nowhere, except for sometimes I managed so send the image as body text, thus not an image, just a long jumble of garbage.
Then I thought it was an email server problem, but when I talked to my ISP, they said their server is rejecting my emails because of a dangerous attachment. That must mean I'm formatting the data wrong, and an email with no attachment goes through just fine.
So then I thought, maybe the data being sent by Frigate is rubbish, so now I'm I responding to the frigate message by pulling a frame directly from the camera, and then trying to format it in Function node.
I can see that the image is pulled correctly, because the image shows up in a parallel viewer node, but the image doesn't survive my Function node.
I am trying to use Nodemailer format to send the image, but I have not been able to find a specific example anywhere where the nodemailer format is sending an IMAGE
Please. I know that this should be an easy thing, and I have read a zillion threads, but I can't get this right and I'm desperate.
What am I doing wrong? Please put me out of my misery.
Here is my stupid flow.
[
{
"id": "6a4432f18e678736",
"type": "inject",
"z": "2d5ffc4e4395cb95",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 670,
"y": 360,
"wires": [
[
"d8e0cb4213559ed2"
]
]
},
{
"id": "e56da89e8c5de884",
"type": "e-mail",
"z": "2d5ffc4e4395cb95",
"server": "redacted",
"port": "465",
"authtype": "BASIC",
"saslformat": true,
"token": "oauth2Response.access_token",
"secure": true,
"tls": true,
"name": "fake.name@fake.com",
"dname": "Email out",
"x": 1380,
"y": 320,
"wires": []
},
{
"id": "2a1754109ab7afb2",
"type": "image viewer",
"z": "2d5ffc4e4395cb95",
"name": "",
"width": "704",
"data": "payload",
"dataType": "msg",
"active": true,
"x": 1050,
"y": 420,
"wires": [
[]
]
},
{
"id": "d8e0cb4213559ed2",
"type": "hikvisionUltimatePicture",
"z": "2d5ffc4e4395cb95",
"name": "",
"topic": "",
"server": "87739017a94d3b9b",
"channelID": "6",
"rotateimage": "0",
"heightimage": "",
"widthimage": "",
"qualityimage": "100",
"cropimage": "",
"textoverlay": "",
"textoverlayXY": "0,0",
"textoverlayWH": "0,0",
"textoverlayFont": "FONT_SANS_32_WHITE",
"urlImageCurrentIndex": 0,
"x": 880,
"y": 360,
"wires": [
[
"df8a62381ef91052",
"2a1754109ab7afb2"
],
[]
]
},
{
"id": "df8a62381ef91052",
"type": "function",
"z": "2d5ffc4e4395cb95",
"name": "Prepare Email",
"func": "var image = Buffer.from([msg.payload]);\nflow.set(\"image1\", msg.payload);\nmsg.attachments = [{\n filename: 'image.jpg',\n content: flow.get(\"image1\"),\n contentType: 'image/jpeg',\n encoding: 'base64'\n}];\nmsg.topic = \"testing testing\"\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1080,
"y": 360,
"wires": [
[
"e56da89e8c5de884"
]
]
},
{
"id": "87739017a94d3b9b",
"type": "Hikvision-config",
"host": "192.168.3.33",
"port": "80",
"name": "House NVR",
"authentication": "digest",
"protocol": "http",
"heartbeattimerdisconnectionlimit": "2",
"deviceinfo": "{\"?xml\":\"\",\"DeviceInfo\":{\"deviceName\":\"House NVR\",\"deviceID\":\"48363630-3737-3734-3636-a41437956562\",\"model\":\"DS-7616NI-E2\",\"serialNumber\":\"DS-7616NI-E21620161013AARR660777466WCVU\",\"macAddress\":\"a4:14:37:95:65:62\",\"firmwareVersion\":\"V3.4.96\",\"firmwareReleasedDate\":\"build 171128\",\"encoderVersion\":\"V5.0\",\"encoderReleasedDate\":\"build 170830\",\"deviceType\":\"IPC\",\"telecontrolID\":255}}",
"debuglevel": "no"
}
]