Gallery Panel for images/videos

Hrm, the file sensor doesn’t pick it up eventually? It should refresh on some timer (I can’t remember the exact off the top of my head).

Not that it’s a solution, but I’d assume it should show up…eventually…

I found a possible workaround, but it is only partially working. To summarize, I now define the files sensor as follows:

- platform: files
  folder: /config/www/media
  name: camera_images
  filter: '**/*.mp4'
  sort: date
  recursive: True

I have a shell command that is executed when home assistant powers up which creates a mount point, mounts a windows share, and then creates a symbolic link to the mounted images in \config\www\media as follows:

shell_command:
  mount_media: mkdir -p /mnt/cameras;mount -t cifs -o username=xxx,password=xxx,domain=WORKGROUP //192.168.1.200/media/cameras /mnt/cameras;ln -s /mnt/cameras /config/www/media

When I display the Gallery Card, it seems to see the files and displays the names of the files (which are formatted to show the date) but the images of each file do not display. Also, if I try to play one of the recordings it simply shows a blank black screen, and hitting the play button does nothing. I assume this is some sort of permissions problem with the files component. I did add the directory /mnt/cameras to the whitelist directory.

Yes, you will need whatever account that runs the HA UI to have access (though I would assume it would be the same as files, which can obviously see the files).

Can you access them via link directly? E.g.:
http://{your ha url}/local/media/{filename}.mp4?

I had a very similar issue recently using the built-in folder integration. My directory is on a NAS and for that reason also listed under the white listed dirs in my main config. The white listing dirs config will cause a fatal error HA on startup and put it into safe mode if the directory wasn’t mounted. The simplest solution for me was to create the directory under the mount point (with the right permissions). When the real directory gets mounted it will simply hide what’s already there. This will allow HA then to start even if the NAS is unavailable.

No, I cannot access the file via http. I should note that the Media Browser has no problems seeing and playing the files. It may be tied to the requirement that the file_path referenced in the files component needs to be located beneath /config. It is curious that the Gallery Card can see the files, but apparently cannot open them.

SOLVED: When home assistant starts, I now mount the SMB share directly to /config/www/media and everything works perfectly. Sorry for the confusion, I’m a Linux beginner and previously thought that mount points needed to be under the /mnt directory. Getting rid of the requirement for a symbolic lnk made everything work.

Thanks to both David and Pieter for their assistance on this issue.

Can me help please in my configuration.yaml

sensor:
  - platform: files
    folder: /config/www/images/camera/
    filter: "**/**/*.jpg"
    name: "gallery_images"
    sort: date
    recursive: True

My files goes there:

But afte check configuration I get error:

Platform error sensor.files - Integration 'files' not found.

Have you installed the files component? It should be a “files” folder under your custom_components folder, and I don’t see it in your screenshot.

If you have hacs you need to add it as a custom integration.

Yes, I use HACS and this https://github.com/TarheelGrad1998/gallery-card component is install

you mean jpg files must be not in
/config/www/images/camera/ but
in
/custom_components/images/camera/ ?

Check the docs of the gallery card. You need a second integration for it to work. There’s a link to it in there — that’s the files integration David is referring to.

Thanks It’s works, my fault

Sorry but I installed:
gallery card with hacs and the folder is in: homeassistant.homeassistant\www\community\gallery-card
Files components is installed manually in: homeassistant.homeassistant\custom_components\files

When I put the following code in configuration.yaml, I have an error:

- sensor
    - platform: files
      folder: /home/homeassistant/.homeassistant/www
      filter: '**/*.jpg'
      name: gallery_images
      sort: date
      recursive: True

expected , but found ‘-’

many thanks

- sensor:

(Note the colon.)

sorry for the newbie error

Just pushed v3.0, which includes:

  • Ability to add Media Sources (see readme for more details)
  • Errors encountered during load are added to the Home Assistant log (and displayed on page)
  • Option for specifying slideshow (auto-advancing after # seconds)
  • Option for sort direction. The default is reverse sorting as before, but you can now turn this off.
  • Clicking on the selected camera or image will maximize the image.

Update should be available via HACS, or just update the gallery-card.js file and clear your cache.

1 Like

David,
This is great stuff. I have one question. The card doesn’t automatically show newly saved files unless I reload HASS Core. Is there a way to make them show up in the card without a reload?

Which method are you using to load the files, the files component or the media source? (Neither should require a restart, but I’m trying to narrow down possible causes).

Also, can you share your YAML, for both the source and the card?

I’m using media source. I found 2 ways to make the new files load:

  1. Reload HASS Core
  2. Refresh browser window (or if using Android App, kill the app and restart it)

Method 2 is easy enough, so don’t dwell on it.

Here is the YAML

  - title: Cat Cam 1
    path: cat-cam-1
    panel: true
    icon: 'hass:cat'
    badges: []
    cards:
      - type: 'custom:gallery-card'
        menu_alignment: Bottom
        entities:
          - path: 'media-source://media_source/local/CatCam1'
            recursive: true
        file_name_format: '%H.%M.%S'
        maximum_files: '20'
        caption_format: '%H.%M.%S'
1 Like

So if you click off to another tab or screen and then come back, does it refresh?

Honestly, I don’t usually stay on the screen expecting to see the latest, it’s more, I come back to it to see what (if anything) has happened on my cameras, and the updates are always there.

Anyway, adding a manual refresh button is something I’ve considered, and yours is definitely an upvote for that. :slight_smile: