📸 Send camera snapshot notification on motion

Thank you @parautenbach

Ah oke that i didn’t know i had to create a map first. My mobile phones can reach https://hass.mydomain.net:8123 i have the HA app installed and is working but there is no /local/snapshot_voortuin.jpg I do get the notification but there is no picture in it.

Were do i create this local directory and / or /config/www/tmp ?
I tested last days by creating

/config/www/tmp
/home/homeassistant/.homeassistant/config/www/tmp/
/home/homeassistant/config/www/tmp/

all that did not work. In the home-assistant.log is still this message /config/www/tmp/snapshot_voortuin.jpg not created no access to path.

Were do i create this map?

1 Like

The directory where your configuration.yaml is located is config so in my case (I run HA in a Python virtualenv and not HA Supervised, HassOS or HA Docker) it would be /home/homeassistant/.homeassistant/www/tmp/ (in other words, drop config). Then, for the external access, www (on disk) becomes local (in the URL).

That makes a lot of sense. I have the same setup i installed HA python virtualenv also in a Ubuntu VM.
I created /home/homeassistant/.homeassistant/www/tmp/ gave it homeassistant user and group with 0777 permissions.

I installed the blueprint again setup the camera: in configuration.yaml created the automation again camera picture is chowing in the automation so thats good to.

Wen i run the automation there is still this eror in de log
2021-03-08 14:18:07 ERROR (MainThread) [homeassistant.components.camera] Can't write /config/www/tmp/snapshot_voortuin.jpg, no access to path!

I put a test image in www/tmp/test.jpg.
This test.jpg is showing wen i go to https://mydomain:8123/local/tmp/test.jpg
so that at least works

But somehow the automation still has no access to /www/tmp/

I changed the www/tmp/test.jpg to snapshot_voortuin.jpg and triggered the automation. Now i do get my test image in de notification of my mobile phone.

But its the test image not the image of the camera because it still can’t write to /www/tmp/

Hi I added this to my Config-file:

image

And then I made this Script:

image

1 Like

We’re the odd balls running HA in a virtualenv (remember that when looking at other things on the forum too). :slight_smile:

I stand corrected on this, so someone with better knowledge, please chime in. I think when you run HA e.g. in Docker, there is an actual config directory. I checked the blueprint (which I don’t use myself as I already had a working setup from almost 2 years ago) and I think you should make the following change.

Change

snapshot_create_file_path: "/config/www/tmp/snapshot_{{ states[camera].object_id }}.jpg"

to

snapshot_create_file_path: "/home/homeassistant/.homeassistant/www/tmp/snapshot_{{ states[camera].object_id }}.jpg"

.

At least, try that for a test. I don’t know if there is some HA magic that will resolve the config path when seen in a blueprint.

Yeah i remember wen i installed HA in a virtualenv the text said you have to do everything yourself. That’s what i’m experiencing now of course and last days many many hours of searching. I knew it would be difficult because of the virtualenv of HA thats why i posting my question here because i was out of options. I’m very thankful with your help.

So oke I changed the
/home/homeassistant/.homeassistant/blueprints/automation/vorion/send-camera-snapshot-notification-on-motion.yaml
The way you suggested after that i restarted HA.
Now wen i trigger the automation i get the notification on the phone without a picture again.
If i check on my desktop https://hass.mydomain.net:8123/local/tmp/snapshot_voortuin.jpg is now created and every time i trigger the automation the picture is renewed so that works.

There is no error anymore in the log but there is still no picture in the notification. Wen i open the webbrowser on my phone and load https://hass.mydomain.net:8123/local/tmp/snapshot_voortuin.jpg the browser can’t load the picture it can’t complete the request says the browser.

But the HA app is working so it is able to connect but somehow i can’t reach the url in the browser anymore wile it could before.

Wen I test https://hass.mydomain.net:8123/local/tmp/snapshot_voortuin.jpg on my wifi connected tablet wich has not installed the HA app the picture is shown so its not a firewall thing but i think the HA app on my phone blocks direct access to https://hass.mydomain.net:8123

@MrBorg,

I tried to add homeassistant: but got an error.
I think i run a different system then you.
I run HA in a Ubuntu python virtualenv.

Thank you for the suggestion.

MrBorg replied to someone else (check the reply arrow in the top right; it caught me out initially).

Your debugging steps with the browser are good. I need to think more. I can’t imagine why it won’t work now. Perhaps try with another phone or just double check your phone’s network settings?

Oh yes duh me
I think i don’t have to tell you i’m new here :grinning:

I set a self-signed certificate in configuration.yaml. I use this certificate also in other local websites. Wen i connect to those other websites Firefox for Android presents a security error and a exception option so i can enter the site. Not so wen i try to connect to https://hass.mydomain.net:8123/local/www/tmp/snapshot_voortuin.jpg then Firefox presents the text that it can’t connect to the server.

I remove the self-signed certificate from HA now i can view the http://hass.mydomain.net:8123/local/www/tmp/snapshot_voortuin.jpg

But the notifications on my mobile are still without a picture

Oke now it works

In /home/homeassistant/.homeassistant/blueprints/automation/vorion/send-camera-snapshot-notification-on-motion.yaml change:

snapshot_create_file_path: /config/www/tmp/snapshot_{{ states[camera].object_id }}.jpg snapshot_access_file_path: '{{ snapshot_create_file_path | replace(''/config/www'',''/local'') }}'

to

snapshot_create_file_path: /home/homeassistant/.homeassistant/www/tmp/snapshot_{{ states[camera].object_id }}.jpg snapshot_access_file_path: '{{ snapshot_create_file_path | replace(''/home/homeassistant/.homeassistant/www'',''/local'') }}'

Thank you @parautenbach for your help :+1:

2 Likes

You’re welcome. Glad you figured out that last bit (I totally missed that).

1 Like

Thankyou so much it works Perfectly. I am so amazed with how well it works. I didnt know I could even take a snapshot from the cameras I had but it worked. I was wondering I know this is out of this scope but do you know if there is a way to have a condition to turn this on. What I am thinking is using the alarmo intergration. Only notify and take a snapshot when the alarm is trigged and it would take a snapshot depending on the sensor that was trigged. That would be the dream but my coding is limited so I am not sure how to get that idea working. But this has shown it is possible.

Realy like this blueprint.
is there any posibility to get it to also send email?`
Would be perfect with an “away” function.
So i dont get pictures when i enter the area

hi @Maindfield, how do you setup the motioneye to send motion detections?

Anyone has an idea how to solve this?

I have this as config in configuration.yaml

binary_sensor:
  - platform: mqtt
    name: "Motion"
    state_topic: "home/motiondetection/camera"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: "motion"

I have this in motioneye under Run A Command:

mosquitto_pub -h 192.168.1.201 -u *user* -P *password* -t home/motiondetection/camera -m '{"state":"ON"}

But the binary sensor never changes status. Should the mqtt ip be the same as the HA IP or does it have an internal ip?
What could be wrong?

Look at the first example in the docs — you’re missing your value_template.

@parautenbach, thanks, i will check this.

Everything works as long as I put at least a 1 second delay-- but the image comes up like this in the notification.
I can find the actual JPG file inside /config/www/tmp but it doesn’t show in the notification.
Any ideas?

I’ve made a slight tweak to add the ability to set an event_object to support smart detections eg with ubiquiti cameras.

1 Like

is it possible to have it go to the camera feed when we click on the notification ?