Camera Snapshots from node red

You have the api node outputting its results to msg.alarmdisarmed but you’re trying to access msg.greatroom.content in the function node where it should be msg.alarmisarmed.content

Thanks. That worked.

Is it possible to send more then one attachment in the same flow/email?

Pretty much the exact same thing but do an api call for each camera and added them to the attachment array in the email.

[{"id":"b8dfca9b.3983e8","type":"inject","z":"5eb3594f.d294b8","name":"","topic":"","payload":"[\"camera.camera1\",\"camera.camera2\",\"camera.camera3\",\"camera.camera4\"]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":194,"y":576,"wires":[["81c0da36.2c7278"]]},{"id":"b242cfff.5de7d","type":"e-mail","z":"5eb3594f.d294b8","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"","dname":"","x":994,"y":576,"wires":[]},{"id":"4ebd7c88.f23b94","type":"function","z":"5eb3594f.d294b8","name":"email","func":"msg = {\n    topic: `Cameras @ ${Date()}`,\n    payload: 'All Cameras',\n    attachments: msg.payload\n}\nreturn msg;","outputs":1,"noerr":0,"x":866,"y":576,"wires":[["b242cfff.5de7d"]]},{"id":"35060d94.be7b02","type":"ha-api","z":"5eb3594f.d294b8","name":"","server":"8d00ebbc.99a928","protocol":"websocket","method":"get","path":"","data":"{\"type\":\"camera_thumbnail\",\"entity_id\": \"{{payload}}\"}","location":"image","locationType":"msg","responseType":"json","x":450,"y":576,"wires":[["ae1183ab.a78d4"]]},{"id":"ae1183ab.a78d4","type":"function","z":"5eb3594f.d294b8","name":"attachment","func":"msg.payload = {\n    \"filename\": `${msg.payload.split(\".\")[1]}.jpg`,\n    \"content\": msg.image.content,\n    \"encoding\": 'base64'\n };\nreturn msg;","outputs":1,"noerr":0,"x":598,"y":576,"wires":[["4bd9657.d4f269c"]]},{"id":"81c0da36.2c7278","type":"split","z":"5eb3594f.d294b8","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":322,"y":576,"wires":[["35060d94.be7b02"]]},{"id":"4bd9657.d4f269c","type":"join","z":"5eb3594f.d294b8","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":738,"y":576,"wires":[["4ebd7c88.f23b94"]]}]
4 Likes

Kind of works. The flow sends an email with the five cameras. But doubles up one of the cameras at random. Different camera each time I inject. Also in Node Red debug window I get “Error Message: Invalid format”

Edit: A closer look I find the first inject fails completely. The second inject sends the email but with the error and the email that I receive is the time stamp on the camera images of the fist inject. If that makes sense.

How would you format this differently for the notify domain? I tried this but couldn’t get it to work.

Very nice :wink: You know what’s a node !!

I will use this topic about a close question…

I need to get the camera url picture to use visual recognition (watson) to know if my car is there or not.

But the watson node want a real url :frowning: Where can I found this in node red ?

Tks

Ps: my thumbnail picture is at /tmp/my-image.jpg but it’s not exposed to the web

I’m trying to figure this one out too. I think I have the flow, but not sure what to put into the notify data box.

Did you find any solution?
I am facing the same problem: which url to specify for Watson

Thanks Kermit! This works for me.

In a few times, it failed to get the snapshot. Is it possible to try take another if it is failed? And is there any node that we can save the image to a folder with timestamp?

Thank you.

I use the call service node to call camera.snapshot, filename: “www/whatever.jpg” (create the www dir in your config dir), and then pass url https://your_ha_host:port/local/whatever.jpg

1 Like

yes I got it but had to install a third node to use my url picture has “base64” because watson dont handle the url or other kind of payload :frowning:

[{"id":"5b275441.c28e9c","type":"debug","z":"bbc1256d.2b84a8","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1050,"y":400,"wires":[]},{"id":"7752e2db.0dd9b4","type":"visual-recognition-v3","z":"bbc1256d.2b84a8","name":"","vr-service-endpoint":"https://gateway.watsonplatform.net/visual-recognition/api","image-feature":"classifyImage","lang":"fr","x":470,"y":160,"wires":[["5b275441.c28e9c"]]},{"id":"8ff64a53.397dc8","type":"inject","z":"bbc1256d.2b84a8","name":"","topic":"","payload":"/share/preau.jpg","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":160,"wires":[["28df0478.04cf2c"]]},{"id":"28df0478.04cf2c","type":"jimp-image","z":"bbc1256d.2b84a8","name":"","data":"payload","dataType":"msg","ret":"buf","parameter1":"200","parameter1Type":"msg","parameter2":"200","parameter2Type":"msg","parameter3":"800","parameter3Type":"msg","parameter4":"600","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":290,"y":160,"wires":[["7752e2db.0dd9b4","b7f76003.86cca"]]},{"id":"74179799.a5cfd","type":"inject","z":"bbc1256d.2b84a8","name":"","topic":"","payload":"/share/salon.jpg","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":220,"wires":[["28df0478.04cf2c"]]},{"id":"b7f76003.86cca","type":"image viewer","z":"bbc1256d.2b84a8","name":"","width":160,"data":"payload","dataType":"msg","x":480,"y":260,"wires":[[]]},{"id":"c4988e25.f2e44","type":"inject","z":"bbc1256d.2b84a8","name":"","topic":"","payload":"/share/atelier.jpg","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":280,"wires":[["28df0478.04cf2c"]]}]

This is my node :wink:
Good luck

Ps: it work, I mean watson recognise my car but on the edge only, firstly the picture was taken from the upper back… Was not fine lol

My flow to send a camera image to my email when the alarm is disarmed no longer works. Getting the error " The websocket command ‘camera_thumbnail’ has been deprecated. " in HA. What is the correct format to grab the image in Node red now? I have tried camera_snapshot and camera.snapshot. they do not work.

image

I know this is an old topic…

Is there a way to save locally or send via telegram the camera snapshot, using this flow?

Thanks

This is what I ended up doing:

1 Like

Yes there is. I have a flow like this set up buy it has stopped working. The issue I have is the snapshot call service node does not save the image any more

THX for your hints, works perfect with my IP Cam to get an jpg file as well as sending this via mail.

→ I look now for an opertunity to grap an forward several pictures, even better to grap and send a smal video. Hints how to would be highly appreciated.

THX M

Greetings All,

I am currently in search of a method to accomplish to same result only instead of an email, I am attempting to have the HA Companion App on my Android device display the notification with an image.

I am able to get as far as having a snapshot taken, and a prompt sent to my phone; though sadly no thumbnail/image is visible.

What are your thoughts?

[{"id":"2e8b5d92a1e3273e","type":"tab","label":"Sandbox","disabled":false,"info":"","env":[]},{"id":"a057ef5eddb425a9","type":"api-call-service","z":"2e8b5d92a1e3273e","name":"Notify Rob's Phone","server":"59c431be.e53a8","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_oneplus_7_pro","entityId":"","data":"{\"title\":\"HA - Notification\",\"message\":\"Trigger Garage Door?\",\"data\":{\"attachment\":{\"content-type\":\"jpeg\",\"image\":\"https://cdn.sparkfun.com/assets/learn_tutorials/9/0/0/home_assistant.jpg\"},\"actions\":[{\"action\":\"Garage_Door\",\"title\":\"Yes Please\"}]}}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":180,"wires":[[]]},{"id":"0e5b4d8f24545df7","type":"inject","z":"2e8b5d92a1e3273e","name":"Manual Test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":180,"wires":[["d1f37f26ee819d43"]]},{"id":"d1f37f26ee819d43","type":"api-call-service","z":"2e8b5d92a1e3273e","name":"Take Snapshot","server":"59c431be.e53a8","version":3,"debugenabled":false,"service_domain":"camera","service":"snapshot","entityId":"camera.garage","data":"{\"filename\":\"/config/www/garage_snapshot.jpg\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":340,"y":180,"wires":[["9f91c3f94d1c06da"]]},{"id":"9f91c3f94d1c06da","type":"delay","z":"2e8b5d92a1e3273e","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":540,"y":180,"wires":[["a057ef5eddb425a9"]]},{"id":"59c431be.e53a8","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

Note: I replaced my local image URL with this image for testing.
https://cdn.sparkfun.com/assets/learn_tutorials/9/0/0/home_assistant.jpg

Thank you for any suggestions,
Rob

Issue resolved!
It was a matter of proper formatting.

Flow Overview:

Call Service Node:

Feel free to import this template and apply to your own use case.

[{"id":"206f8fe0defc3dab","type":"api-call-service","z":"2cbd4bd1825e9d2d","name":"Notify Rob's Phone","server":"59c431be.e53a8","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_oneplus_7_pro","entityId":"","data":"{\"title\":\"House - Notification\",\"message\":\"Trigger Garage Door?\",\"data\":{\"actions\":[{\"action\":\"Garage_Door\",\"title\":\"OPEN / CLOSE\"}],\"image\":\"https://raw.githubusercontent.com/home-assistant/assets/master/logo/logo.png\"}}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":670,"y":80,"wires":[[]]},{"id":"59c431be.e53a8","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
3 Likes

Okay, this is weird… have been trying to get camera snapshot to my Android device for about the whole morning and nothing I tried seemed to work.
In the end I saved the snapshot name without and underscore (_) in the filename and all of a sudden it works.

File stored in www folder is publicly reachable through https://mydomainname/local/filename.jpg and is viewable. If however there is an underscore in the name the file is just not viewable anymore. Not in a browser, not in a notification. So https://mydomainname/local/file_name.jpg does not work altough the file is actually in the folder.