Automation Axis-Camera Snapshot / Videoclip

Hi there,
I want to send screenshots of any motion on my camera to my iphone.

this is my automation:

alias: Cam Motion
description: ""
triggers:
  - type: motion
    device_id: 8e4ba3445bff615bfed0ebc1cf8db983
    entity_id: fb29f9b0a71e2947e28becb1375c08b1
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 0
      seconds: 3
conditions: []
actions:
  - action: camera.snapshot
    target:
      entity_id:
        - camera.q1615_0
    data:
      filename: /media/camera/snapshot.png
    enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - data:
      message: Cam Motion
      data:
        attachment:
          url: /media/camera/snapshot.png
          content-type: image/png
        push:
          sound:
            name: default
            critical: 1
            volume: 1
    action: notify.mobile_app_ip16b
mode: restart

the snapshot.png is always placed in the folder, can confirm this.
I also get the notification on my phone, but the picture is not shown.
getting the error:

also tried jpg instead of png - same result.
Any ideas about this?

EDIT:
Checked out notification attachments:

due to this a png with 260kb should not be any problem :frowning:

ok, figured out, that there are a few steps to do:

  1. make a folder www within configs-folder.
    see https://companion.home-assistant.io/docs/notifications/notification-attachments

  2. changed automation config to:

alias: Cam Motion
description: ""
triggers:
  - type: motion
    device_id: 8e4ba3445bff615bfed0ebc1cf8db983
    entity_id: fb29f9b0a71e2947e28becb1375c08b1
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 0
      seconds: 3
conditions: []
actions:
  - action: camera.snapshot
    target:
      entity_id:
        - camera.q1615_0
    data:
      filename: /config/www/snapshot.png       # <-- write into www folder
    enabled: true
  - data:
      message: Cam Motion
      data:
        image: /local/snapshot.png     # <-- read from LOCAL folder, which is exposed on the web
        push:
          sound:
            name: default
            critical: 1
            volume: 0
    action: notify.mobile_app_ip16b
mode: restart

now trying to add some action to open mediastream on the app, once opened the notification :slight_smile:

www has no authorization protection and is exposed to the internet. If your instance is reachable through the internet, then everything in that folder can be accessed without a user name and password.

To share files from /media you must add the path to the allowlist_external_dirs inside configuration.yaml

homeassistant:
  ...
  allowlist_external_dirs:
    - '/media'

this was my first try, but didn’t worked out.
due to my setup is behind a reverse-proxy - the www is not accessible :slight_smile:

so my final acrtions part is looking like

actions:
  - action: camera.snapshot
    target:
      entity_id:
        - camera.q1615_0
    data:
      filename: /config/www/snapshot.png
    enabled: true
  - data:
      message: Cam Motion
      data:
        image: /local/snapshot.png
        url: /dashboard-kamera/   # <-- this is the dashboard which will be opened on-click
        tag: Cam-Motion
        persistent: true
        visibility: public
        push:
          sound:
            name: HummingbirdCompletion_Haptic.caf  # <-- different ringtone
            critical: 1
            volume: 1
    action: notify.mobile_app_ip16b

but I am still figuring out some problems.
my internal and external url is same url (which is my reverse proxy)
but:

  • On Wifi network, notifications are reaching out.
  • on cellular - no notification is arriving
    → error:

IDK that it will open the folder and www is changed to local. Try with the full link to the pic eg http.../local/snapshot.png just to make sure.

The error is complaining that the data values need to be strings i.e. in quotes " ". I don’t often use yaml and am unsure which values need to be in quotes. If you look at the docs the path to the pic, for starts, needs to be in quotes.

https://companion.home-assistant.io/docs/notifications/notification-attachments#example-action

thanks @Mikefila - can confirm even the full url is not accessible.
with the last release (2025.3 - I updated yesterday after my automation tryings), the automation also seems to be working on cellular