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

Caption formatting doesn't show properly or appears as NaN:NaN. #11

Closed consandstuff closed 2 years ago

consandstuff commented 3 years ago

I'm using this format for my video captions: %d/%m %H:%M but in the card it only has 1 digit for day, month, hours and minutes (instead of two), so if the file has this name 2021_04_15_09_57 the caption shows as: 5/4 9:7 [00:16], instead of 15/04 09:57.

This is my yalm config:

type: 'custom:gallery-card'
entities:
  - camera.front_cam
  - path: 'media-source://media_source/local/folder-name'
    recursive: false
maximum_files: '10'
file_name_format: '%YYY_%m_%d_%H_%M'
caption_format: '%d/%m %H:%M '
menu_alignment: Responsive

image

Also, if the filename has the hour as 1 digit (9_57 instead of 09_57) the card shows the caption as NaN:NaN.

The rest of the card works great though! really happy with your work.

TarheelGrad1998 commented 2 years ago

I think this is fixed with 3.1. I found that some characters (e.g. space) where getting URL encoded (e.g. %20) which threw off the calculation. Try that update and let me know if it's still broken.