Issue with attaching a camera.snapshot to a phone notification

Hi all,

I am attempting to send a notification to my phone triggered by my front camera broadcasting an MQTT message indicating a motion event. The notification needs to include an attached snapshot of the camera feed (the feed is available within HA) but I’m having trouble getting the snapshot to appear in the notification at all.

Here is the code for my automation:

alias: FRONT-CAM Alert Notification
description: ''
trigger:
  - platform: mqtt
    topic: Agent/cameras/front-cam/alert
    payload: 'true'
condition: []
action:
  - service: camera.snapshot
    data:
      filename: /config/www/frontcam.jpg
    target:
      entity_id: camera.front_cam
  - service: notify.mobile_app_pixel_4a
    data:
      message: 'The front camera was triggered at {{now().strftime(''%H:%M %d-%m-%Y'')}}'
      title: Camera alert!
      data:
        image: 'https://[MYDOMAIN]/local/frontcam.jpg'
mode: single

I primarily followed this guidance to set this up: Standard Attachments | Home Assistant Companion Docs

When I test fire this automation I get a snapshot appearing in /config/www/images/frontcam.jpg and a notification sent to my android device as expected, but that notification does not appear with an attached screenshot image. If I try to access what I think is the correct URL https://[MYDOMAIN]/local/frontcam.jpg from a PC I get a 404 error message. If I swap the image URL in the automation for something hosted publicly e.g. the HA logo URL as listed in the guidance, it correctly appears within the phone notification.

How can I get the snapshot to become attached to my notification?

Thanks

I have fixed this now!

For anyone in a similar situation who may stumble across this in the future, my solution was to add my external URL to Home Assistant’s settings under Configuration>General and restart the server. This was missing as I’d only just set up external access using a reverse proxy and it must have been preventing access to the images.

2 Likes