TarheelGrad1998 / gallery-card

A custom card for Home Assistant that will display images and/or videos from a folder in the style of a gallery.
97 stars 30 forks source link

Photo's listed in newest time order, but oldest date #19

Closed chrisrpi closed 2 years ago

chrisrpi commented 2 years ago

HI ... fantastic card...many thanks.

On the second day of using it (to show movement snapshots from my camera) I noticed that today's pics are shown at the bottom of the list. I have the reverse sort box ticked.

Although the newest day is shown at the bottom, within a given day, the pics are sorted correctly with the newest time first.

If I look at the pics in media browser, they are listed in newest date/oldest time order. The same happens in file editor. The pic names are generated in node red and are datestamped as follows ... {"filename":"/media/snapshot_{{now().strftime('%H:%M %d-%m-%Y')}}.jpg"} ... can't imagine this affects how they are listed?

Not sure if this is an issue with how I have home assistant set up or if it is a card issue?

Would be very grateful for any advice.

Many thanks indeed, Chris.

TarheelGrad1998 commented 2 years ago

Yes, unfortunately this is a limitation of the media source (which I assume you're using). It returns the file names but not the actual created date, so the files get sorted only by name. In your case that is sorting time before the date, which is not ideal.

You only really have two options at the moment:

  1. Change your node red to name the files something like %Y-%m-%d %H:%M, or
  2. Switch to using the files component (link) which can pre-sort the files by creation date.

If home assistant ever provides more file metadata in a media source I will update the card to better sort.

chrisrpi commented 2 years ago

Ah...that makes perfect sense now.

Thank you for such a fast response, I shall make the change in Node Red as suggested.

Thank you!

kalhimeo commented 2 years ago

First thanks a lot for your great card ! As you can only get the filenames from HA medias, I wondered if it would be possible to use the data from the "file_name_format" to sort the media files by date ?

TarheelGrad1998 commented 2 years ago

First thanks a lot for your great card ! As you can only get the filenames from HA medias, I wondered if it would be possible to use the data from the "file_name_format" to sort the media files by date ?

That never occurred to me for some reason, but good idea!

I'll add to my backlog to add an option something like "sort by formatted name"

kalhimeo commented 2 years ago

thank you very much :-)

TarheelGrad1998 commented 2 years ago

This should be possible in v3.3 just released by switching on the parsed_date_sort option. Thanks to @kalhimeo for the assist.