luixal / lovelace-media-source-image-card

A Lovelace custom card for showing images stored in Media Source
GNU General Public License v3.0
21 stars 0 forks source link

bug: `media-source://` can't be a part of template #10

Closed 532910 closed 7 months ago

532910 commented 7 months ago

this works:

image: media-source://{{ states("sensor.photo") }}

with template sensor's template set to

media_source/local/share/{{ '%02d' % range(0, 20) | random }}.jpeg

this does not:

image: {{ states("sensor.photo") }}

with template sensor's template set to

media-source://media_source/local/share/{{ '%02d' % range(0, 20) | random }}.jpeg
luixal commented 7 months ago

Umm... not sure, haven't tested, but using media-source:// string in a template sensor should work.

Can you paste some examples and the resolved string from the template? If you can paste the error shown in the card, the better.

Thanks!

532910 commented 7 months ago

no error, just nothing is shown could you try it to check, please template is resolved correcty

532910 commented 7 months ago

image image image

luixal commented 7 months ago

Thanks for the info, I got your point.

In your card config, instead of:

image: "{{ states('sensor.test') }}"

it was intented to be like this:

image: |
  {{ states('sensor.test') }}

anyway, it doesn't work either as it tries to load the url as a public image instead of a media source one.

I already have an idea of what's going on, but I will look into this and publish a fix.

Thanks!

luixal commented 7 months ago

Hi,

I just release v0.2.5 that should fix this, can you update and try it out?

Thanks!

532910 commented 7 months ago

Yep, can confirm it works now as expected!