Picture Card - How to display last uploaded image in a Picture Card? (used local_file camera instead)

I have an automation that takes a snapshot from one of my cameras and stores it in a specific folder:

action: camera.snapshot
target:
  entity_id:
    - camera.1_outdoorcam
data:
  filename: >-
    /media/SecurityCams/Sunrise/1_Outdoorcam_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg

I want to display this image for the rest of the day in a Picture Card, but I can’t seem to figure out the correct path, not even if I just use a static file name :frowning_face:

This

type: picture
image: /media/SecurityCams/Sunrise/1_Outdoorcam_20241029-063511.jpg

doesn’t work and neither does this (with or without the port info):

type: picture
image: \\192.168.7.11\media\SecurityCams\Sunrise\1_Outdoorcam_20241029-063511.jpg

Any hints?

Either store it in config/www instead (and use /local) or add the path to your allowed external directories. See: https://www.home-assistant.io/integrations/homeassistant/#allowlist_external_dirs

Hmmm - tried the external_dirs before and couldn’t get it to work.
Unfortunately, there’s no example in the docs that show how to add, e.g. the ‘media’ folder on my HA instance that runs at 192.168.7.11.

Adding http://192.168.7.11/media to the config file - with or without “” - returns the error:

Not a directory 'allowlist_external_dirs->0', got 'http://192.168.7.11/media'

If I add the same entry in a section called allowlist_external_urls it doesn’t throw an error message, but still neither of the ways above nor using something like http://192.168.7.11/media/SecurityCams/Sunrise/1_Outdoorcam_20241029-063511.jpg for the image path works.

  allowlist_external_dirs:
    - /media

or

  allowlist_external_urls:
    - http://192.168.7.11/media

OK - thanks. This seems to work.

Still took me a while to find the right way to display the image because the file name shows when it was taken - couldn’t find a way to use the Picture Card as I originally intended.
So, I ended up setting up a camera with a local_file entry in the configuration.yaml

camera:
 - platform: local_file
   name: TrashCam Latest
   file_path: /media/sun.png

The drawback of the camera setup is that I can’t use a template in the configuration.yaml for the image name, so I have to use the path and fixed file name of an image that already exists in the /media folder and then run an additional action: local_file.update_file_path once HomeAssistant is up & running.

triggers:
  - event: start
    trigger: homeassistant
actions:
  - action: local_file.update_file_path
    target:
      entity_id:
        - camera.trashcam_latest
    data:
      file_path: >-
        /media/SecurityCams/1_OutdoorCam/{{ states('input_text.outdoorcam_snapshot_time') }}.jpg