Failed to Load Attachment - iOS notification media source

Hello there,

I’m trying to attach a snapshot image whenever the camera detects a motion. But I’m getting an error:

Failed to load attachment
Response status code was unacceptable: 404

I can see that the snapshot is saved in the /media/local/ folder, and the notification message is working, but it can’t load the image.

Here’s my automation:

- alias: Motion Detected
  trigger:
  - platform: state
    entity_id: binary_sensor.living_room_camera_motion_detected
    to: 'on'
  action:
  - service: camera.snapshot
    target:
      entity_id: camera.living_room_camera
    data:
      filename: '/media/local/living_room_camera_motion-detected.png'
  - service: notify.ios_phones
    data:
      message: Motion detected in the living room.
      data:
        attachment:
          url: '/media/local/living_room_camera_motion-detected.png'
          content-type: png
          hide-thumbnail: false

Do I need to add anything in the configuration.yaml to be able to send images from the media folder?

Solved the problem.

For some reason, the png file can be access in path “/media/local/loca/<image.png>”
And I’m not sure why it’s configured that way. But now the image can be viewed in the notification.

I didn’t have to add anything in the configuration.yaml, like allowlist_external_dirs. None.

I also had to add a 5 second delay to prevent Home Assistant from sending the previous saved image.

- alias: Motion Detected
  trigger:
  - platform: state
    entity_id: binary_sensor.living_room_camera_motion_detected
    to: 'on'
  action:
  - service: camera.snapshot
    target:
      entity_id: camera.living_room_camera
    data:
      filename: '/media/local/living-room_motion-detected.png'
  - delay: '00:00:05'
  - service: notify.ios_phones
    data:
      message: Motion detected in the living room.
      data:
        attachment:
          url: '/media/local/local/living-room_motion-detected.png'
          content-type: png
          hide-thumbnail: false
2 Likes

Hi,

I am experiencing the same issue. 404
Reviewed your post, not sure what you changed to get it working properly.
Please advise…

Thank You

For anyone who runs across this post and is confused (like I was) about what the fix was, if you are storing files in /media/folder/filename.png when you take a snapshot, you can then access that content at /media/local/folder/filename.png when using that image to send a notification (note the addition of /local after /media).

The documentation states:
“A file stored in /media/file.jpg on-disk is represented by /media/local/file.jpg in the notification. Note the addition of the local part of the path.”

4 Likes