Node-RED Camera Snapshot with Telegram (snapshot wrong camera)

I’m new to home assistant and node-red. But I already managed to made quite a few nice automations. Only now I have something that I can’t figure out. Hopefully someone can tell me where this goes wrong.
I will explain the step-by-step guide of what I have done.

First I created the cameras in home assistant via motioneye:

The camera of which I want the snapshot is Camera1:

Then in Node-RED I have made the following simple flow.
Which works! Because I do receive a snapshot in Telegram.
The only problem is that I don’t receive it from Camera1:
image

The “Take Snapshot” looks like this:

Maybe the problem is in the “Data” field:
{“filename”:"/config/www/snapshot"}

The “Send Photo” looks like this:


“Data” field:
{“file”:"/config/www/snapshot",“caption”:“Er staat iemand voor de deur”}

Can someone explain to me what’s going wrong. What is not right here so I receive a snapshot of Camera4. While this should be Camera1.

Here you see (blurred) snapshot of Camera 4
image

Please, anyone can point me in the right direction?

In the address where you attach the snapshot replace www with local

“file”:"/config/local/snapshot"

Can you explain why “www” should be “local”. I’m curious and would like to learn what this difference would make in theory?

Of course I have also tried it but unfortunately it does not work. In “take snapshot” and in “send photo” I changed it to from “www” to “local”.


But after I click on timestamp I see two green dots at “take snapshot” and at “send photo”.
image

Only now nothing is happening. Nothing is coming in on Telegram now. If I put it back to “www” it works and I do receive a photo via telegram. Only from camera4 and not from camera1 as I indicate the flow. :frowning:

So unfortunately it is not the solution for me or I must have done something wrong.
I even tried it by changing “filename” to “file”. As you typed in your post, but then I get an API error.

The change to local is explained in the companion app wiki. It may only need to be changed if you send it a pic to the app, I am not sure that it applies to telegram. One thing to try place a pic in the www folder. Then in a browser use http://your.ha.ip:8123/local/pic_name.jpg You should see the pic in the browser.

You should also add the file type eg .jpg after the file name. Lastly go to dev tools and use call_service/send_photo try to send the photo from ha to make sure there isn’t another problem outside NR

Thank you for your answer, I will try this as mentioned this weekend.

It now works!
Did a lot of trouble shooting, the “local” will not work only.
This must be “www”, is this a problem to keep it “www”.
(because it works now)

This is how it looks now:
{"filename":"/config/www/snapshot.jpg"}

{"file":"/config/www/snapshot.jpg","caption":"Er staat iemand voor de deur"}

There is a general problem with the www folder, it’s not protected by home assistant authentication. If you use https vs a VPN, if someone had the address they would be able to view the folder. If you’re on a VPN and your instance is not exposed to the internet it’s much less of a problem.

There are 2 ways to handle this. Since it doesn’t seem you are saving this for any period of time aside to send a text, you can use the entity picture.

The data section drop down change to j;expression

image

then change the file path to

"file": $entities('camera.kameraframsidan').attributes.entity_picture

just change the camera entity

The other is to use the media folder for storage. That’s a little more involved but is protected by home assistant authentication

Thank you for your answer.
I will try to change it to local instead of www.

No idea why it now will work with www, but not in local.
My Home Assistant works on a QNAP NAS in VM.

Changing www to local does not add authentication, you have to store the pictures in the media folder for that.

not sure what you mean with that.

I was referencing your response. If the intent here was to change for security reasons ie you want the pictures protected by home assistant, then changing from www to local will not protect the files.

To protect the files, they need to be stored in the media folder.

The

"file": $entities('camera.kameraframsidan').attributes.entity_picture

throws an syntax error:

Syntax error: “:”

The red outline means that there is a formatting error. Blue means the format is correct.

The data need to be in braces
{ "file": $entities('camera.kameraframsidan').attributes.entity_picture }

unfortunately it doesn’t work it doesn’t error but just wont send anything.

this is wat “entity_picture” says on developer:

entity_picture: /api/camera_proxy/camera.front_door?

it’s a Ring video doorbell although i believe its a common one there is hardly any info about it

EDIT the saving to /www/ works but as you said… isn’t secure and i would like it to send it directly

EDIT 2

with this:

{
“title”:“Title”,
“message”:“message body”,
“data”:{
“image”: $entities(‘camera.front_door’).attributes.entity_picture
}
}

i get this:
Imgur

but nothing happens in telegram

Jeroen, did you manage to work this out?
I did otherwise I can share my flow with you.

2 Likes

@LJ80 I am also very interested if you have anything to share !

@mackelen

This is my flow, sending two snapshots from two different dahua camera’s.

You should consider using /media vs /www to store your snapshots. www has no authentication and is exposed to the internet. media is protected by HA authentication.

thanks for notice me.

can you simple explain me what exact I have to change?
like I can copy paste it or something.

{“filename”:“/config/www/snapshot.jpg”}

change to?