# NodeRed with Hikvision

**URL:** https://discourse.nodered.org/t/nodered-with-hikvision/46514
**Category:** General
**Created:** [31 May 2021 15:28 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514 "2021-05-31T15:28:42Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [31 May 2021 15:28 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/1 "2021-05-31T15:28:42Z")

</div>

Hello everybody

I have a Hikvision recorder at home, now I would like to download a momentary picture via Nodered and send it to my mobile phone .. preferably on Whatsapp .. Does anyone know how to do this?

I have already downloaded these Notes ([https://flows.nodered.org/node/node-red-contrib-hikvision-ultimate](https://flows.nodered.org/node/node-red-contrib-hikvision-ultimate)) and tried them out a little, but I haven't got any further ...

Many Thanks

---

<div class="post-metadata">

### Author: ![smithy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smithy/32/37804_2.png) [@smithy](https://discourse.nodered.org/u/smithy)
#### Post date: [31 May 2021 17:09 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/2 "2021-05-31T17:09:54Z")

</div>

You might want to compliment with Pushover nodes, not sure how featured the WhatsApp API is, you should also take a look at Telegram.

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [4 June 2021 14:32 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/3 "2021-06-04T14:32:14Z")

</div>

I decided on Telegram .. And I have already set up Telegram so that I can send messages .. What do I have to do if I want to send a picture?

---

<div class="post-metadata">

### Author: ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)
#### Post date: [4 June 2021 14:35 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/4 "2021-06-04T14:35:06Z")

</div>

> [@automati](#):
>
> What do I have to do if I want to send a picture?

You have to lookup the documentation for how to do that

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [4 June 2021 18:04 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/5 "2021-06-04T18:04:51Z")

</div>

Something like this in a 'function' node should work...  
 ![Screen Shot 06-04-21 at 07.03 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/8/f8bd7caafbe0d7f20037417f95f279f824e61245.jpeg)  
Replace 'content' with the path to your image file.  
'Caption' could just be... caption: "My caption" (In this example I'm getting it from a flow variable.)

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 10:47 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/7 "2021-06-06T10:47:11Z")

</div>

![nodered](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d4e9a1853345df2b7afc4688a7838a38d5202fa5.png)

 ![function](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/58fee295d2df94f1d40f740ad3080fafff9305be.png)  
 ![ssh](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/5116230ce35e29d10b7f2df0d8eb140d2b073604.png)

it doesnt work, what is wrong?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [6 June 2021 10:49 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/8 "2021-06-06T10:49:45Z")

</div>

Does the image open in an image viewer (is it a valid image)?

Attach a debug node to both outputs of the gray camera node - let me see what comes out of it.

Lastly, you dont need to even write a file - you can (potentially) send the image directly to telegram

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [6 June 2021 11:04 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/9 "2021-06-06T11:04:03Z")

</div>

Is the image actually stored in a directory called 'root'?  
that seems very unusual. I see that the owner of the image is 'root' so there may be a permission issue accessing the image.

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 11:28 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/10 "2021-06-06T11:28:49Z")

</div>

![photo flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60df61e00029126fda01595a19b445c40752fb0d.png)

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 11:30 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/11 "2021-06-06T11:30:19Z")

</div>

![photo flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60df61e00029126fda01595a19b445c40752fb0d.png)

Can the size of the picture still play a role?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [6 June 2021 11:31 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/12 "2021-06-06T11:31:06Z")

</div>

I need to see the debug output - is it a buffer? a base64 string?

> [@Steve-Mcl](#):
>
> Attach a debug node to both outputs of the gray camera node - let me see what comes out of it.

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 11:35 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/13 "2021-06-06T11:35:41Z")

</div>

![debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/a/dab8a7c6b60c7eee34928376b9f302be608dfe7e.png)

Uploading: debug.PNG...

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [6 June 2021 11:39 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/14 "2021-06-06T11:39:45Z")

</div>

try this...

- delete file node
- connect camera node to function
- changing your function to ...

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

return msg;

```

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 11:44 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/15 "2021-06-06T11:44:30Z")

</div>

I just have to adjust the chat ID?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [6 June 2021 11:45 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/16 "2021-06-06T11:45:49Z")

</div>

yes, to the correct chat id.

I dont know if it will work with base64 image - give it a go & let me know. If it doesnt work I'll show you how to convert it to a buffer (that will work)

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 11:48 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/17 "2021-06-06T11:48:26Z")

</div>

did not work

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [6 June 2021 12:04 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/18 "2021-06-06T12:04:21Z")

</div>

As i suspected - but worth a try - now we know base64 doesnt work.

there are 2 options...

#### 1. best option

if that gray camera node can return a buffer - change it to return a buffer & it should work

  

#### 2. alternatively, convert base64 img uri to buffer

change function code to this...

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

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

```

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 12:27 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/19 "2021-06-06T12:27:43Z")

</div>

didn't work either .. am I doing something wrong?  
 ![sdf](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/2/d24dc48e3056a2cec2e1848fc686ab8bdf6b05a7.png)

 ![sfd](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/09d17f38e795c74eac768f7ccf2efc4ab6e39a33.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [6 June 2021 12:31 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/20 "2021-06-06T12:31:22Z")

</div>

> [@automati](#):
>
> am I doing something wrong

you need to return the msg at the end of the function (i assumed you realised that sorry)

add `return msg;` to the end of the function.

---

<div class="post-metadata">

### Author: ![automati](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@automati](https://discourse.nodered.org/u/automati)
#### Post date: [6 June 2021 12:59 UTC](https://discourse.nodered.org/t/nodered-with-hikvision/46514/21 "2021-06-06T12:59:40Z")

</div>

it worked! Thank you so much!

[Next page](https://discourse.nodered.org/t/nodered-with-hikvision/46514.md?page=2)
