Camera - Send & Save snapshot to mobile device when motion is detected with Conditions. Now with Custom Triggers!

Hi!
Do you have the paid variant of Home Assistant?
If so, you find in the settings > Home Assistant Cloud > Remoteaccess the Link to your Homeassistant Server.

I guess this is necessary to access the snapshot.

This my Yaml:

alias: Klingelnotification mit Bild
description: ""
use_blueprint:
  path: TheRealFalseReality/send_snapshot_conditional.yaml
  input:
    condition: []
    conditionSave: []
    camera: camera.haupttor_snapshots
    notify_device: my_iphone_entity
    is_ios: true
    sensor: binary_sensor.klingel_binary_sensor
    data_clickaction_url: >-
      [here you have to put in the path from the Remoteacess]/local/Rrring/Door/last_motion.jpg
    file: " /config/www/Rrring/Door/last_motion.jpg"
    archive_file: " /config/www/Rrring/Door/archive/motion_{{ now().strftime(\"%Y%m%d-%H%M%S\") }}.jpg"
    notification_title: 🔔 Es klingelt oben!

Hmm, you need the remote access url path if using Home Assistant Cloud? I am using DuckDNS so I may have never encountered that issue before.

Hi,

can someone give detailed instructions to configure the media folder to save snapshots please?
I have HASSOS. These are my steps:

  • manually created a “media” folder in the same folder where configuration.yaml is (with File Editor)
  • added the following to the configuration.yaml:
homeassistant:
  media_dirs:
    local: /config/media
  • restarted HA
  • used the following in the File Path field of the Blueprint:
    /media/local/last_screenshot.jpg

… but I can’t see any file in that folder, and I get the “failed to load attachment” in the Companion App.
What’s wrong?

it saves in /media which is not actually in the /config directory. The /media/local is only for the notification for the blueprint and not the actual directory. Got to “Media” in HA, use the sidebar, → “My media” → and see if last_screenshot.jpg is there. If you use a File Explorer add-on, /media will be in the root directory of HA.
Try using the blueprint with all the defaults and see if it works. It seems like the directory is misconfigured. It was a lot to understand when I first setup the blueprint, I really had to read the documentation in order for the media to load, but the defaults should work and you may not need to do the media_dirs at all.

1 Like
 media_dirs:
    local: /media
    music: /media/int-sdb1/Music

Should look more like that

1 Like

Tried with all default parameters.
The screenshot has been created and saved in [root]/media/snapshots/nameofthecamera/ folder.
I can see the file from the Terminal, not from File Explorer add-on which can’t go back from /config.
I can’t see/load the picture from Media in the left HA menu because that folder is not shown at all.

I still receive a “failed to load attachment” in the Companion App.

About my config in the configuration.yaml, I followed this suggestions.
I believe that there are different behaviours based on the type of HA installation you have, mine is HASSOS.

Hey guys, thank you for the great blueprint.
Everything is working fine except that I’m getting 2 notifications at the same time.
Companion app notification history shows that I’m getting 1 under “Websockets” and one under “FCM”

Any ideas?

ok, I’ll look into this this weekend

is it just with this blueprint or all HA notifications in general?

Just this blueprint, weird

You should be able to alter the path of the image to anything you choose, just make sure you have access to it, either via Home Assistant Cloud or DuckDNS, otherwise you may only get an image on local network.

If you can, save an image to you HA instance, go into services and use the notify service to send that image to your device, if it works, then it is my blueprint. If you have the same error, it is your instance. Lemme know your results Documentation. If your image is saved into /media you need to alter the URL to /media/local. Also, if ALL else fails, try using your /config/www folder, replacing /www with /local.

Example, place a jpg into /config/www, then in your bowser, navigate to <YOUR_HA_URL>/local/<FILENAME.JPG>. Those files are hosted on your device but accessible without authentication on the internet. So not recommended to use store sensitive images there, which is why I use the /media folder by default.

I did some tests with the notify service.
I succesfully sent an alert with a jpg attach with the following config:

configuration.yaml

homeassistant:
  media_dirs:
    local: /config/media
service: notify.mobile_app_dadox
data:
      title: TEST
      message: test message
      data:
        attachment:
          content-type: jpeg
          url: /media/local/snapshots/last_motion.jpg
        push:
          sound:
            name: default
            critical: 1
            volume: 1

Then I put the same path (/media/local/snapshots/last_motion.jpg) to your blueprint, keeping all the other fields with the default parameter … but I got the “failed to load attachment” message :frowning_face:

remove the /local in the blueprint URL, the blueprint replaces /media with /media/local so it looks like the final URL it is going to load is /media/local/local/snapshots/last_motion.jpg.

Here is the actual code

snapshot_access_file_path: '{{ snapshot_create_file_path | replace(''/media'',''/media/local'')  }}'```

where snapshot_create_file_path should be /media/snapshots/last_motion.jpg
so the final URL becomes /media/local/snapshots/last_motion.jpg

The blueprint’s default path is /media/snapshots/{{ states[camera].object_id }}/last_motion.jpg.

Still not working.
This is now the blueprint url:

/media/snapshots/last_motion.jpg

and this is the message I get:

So I added this to configuration.yaml:

homeassistant:
  allowlist_external_dirs:
    - /config/media/snapshots

but I got the same error.

/media is not in /config but in root. I’m not sure why it cant get your image. What kind of HA install are you using?

try using /media/snapshots or /config/www (but remember to replace /config/www with /local in the notification) or any other folder that you have write access to.

shit, I will have to update the blueprint to support files in /www natively though. But it looks like you cannot write to /media at all which may be an underlying issue.

They would have to be in here either way I bet. (In order for something else to write to the folder)
Home Assistant Core Integration - Home Assistant.

1 Like

Try

  media_dirs:
    media: "/media"

thanks for your help! Always appreciated

1 Like

I’ve updated it to support the /config/www, try using the file path as /config/www/snapshots/{{ states[camera].object_id }}/last_motion.jpg and see if you can save the image there. This will expose the image to the internet though, but it seems like you have write issues.