NodeRed with Hikvision

Steve just beat me to it.

I was going to say... try this out - I've put a 'jpg' on my server for you to try.

msg.payload = { chatId: "xxxxxxxxxxxx", 
                type:"photo", 
                content:"http://resources-area.co.uk/pics_of_places/san_francisco.jpg",
                caption:"Picture from the front camera"};

return msg;
1 Like

Is there still a way to save the picture first? because I want to take a picture when there is movement, but only send it if the door contact opens later ... for that I would have to save the picture first and then retrieve it?

It worked! So I have the wrong file path with me?

You can store the picture in flow/global context or you can write the buffer to a file for later retrieval.

e.g..

split that function into 2 parts and put a change node or file node in between them

function 1 --> change node --> function 2 --> telegram

function 1 - convert image to buffer

var imgBase64 = msg.payload;
var pos = imgBase64.indexOf("base64,");
imgBase64 = imgBase64.substr(pos + 7);
var imgData = Buffer.from(imgBase64, "base64");
msg.payload = imgData;
return msg;

change node

set flow.image to msg.payload

function 2 - build the telegram msg

msg.payload = {
  content: msg.payload,
  caption: `Image from camera`,
  type: 'photo',
  chatId: xxxxx // << update this
}
msg.payload.options = { parse_mode: "Markdown" };
return msg;

Depends where the image is located.
In my last posting the image is on a server.

If it was located in your Pi then you could use (for example)...

content: "/home/pi/myImages/filename.jpg",

As Steve said... there are many ways to 'store' your image.

On my home security system I have four RPi-Zero-Ws each fitted with a Pi camera and an infrared detector. Whenever infrared is detected the RPi-Zero-W sends the captured image to an FTP server running on my main RPi-4B which then sends the image via Telegram to my mobile phone.

What should this change node look like?

:arrow_up: like that.

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