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

Picture Name String Stored in Entity? #3

Closed RJ-Make closed 10 months ago

RJ-Make commented 11 months ago

Thank you for your source image card. How can I use a picture name stored in an Entity?

The picture name is stored in: sensor.mqtt_12345_blueiris_front_lower_cam_image_path

This works

type: custom:media-source-image-card
image: >-
  media-source://media_source/local/camalerts/Alerts/IFU.20231101_100328.111999.3-1.jpg
entity_id: input_boolean.cam_lower_front_msg_active
apply_grayscale: false

This does not work

type: custom:media-source-image-card
image: >-
  media-source://media_source/local/camalerts/Alerts/{{states("sensor.mqtt_12345_blueiris_front_lower_cam_image_path")}}
entity_id: input_boolean.cam_lower_front_msg_active
apply_grayscale: false
luixal commented 10 months ago

Hi @RJ-Make you can now use templates in the image field of the card.

You can use jinja templates (like the one in your example) and also javascript templates, I think this last ones are better :)

Publishing new version now.

RJ-Make commented 10 months ago

Oh VERY nice, working almost perfectly... except one (pretty big) issue.

The card is for forcing a rapid page refresh, making it almost impossible to navigate to the card on the page?

I'll try the javascript example are report back.

Thanks you for all your hard work. This one feature makes this card a must-have for me.

RJ-Make commented 10 months ago

So I tried the JavaScript example and the 'problem' persists.

luixal commented 10 months ago

Not sure If I'm able to reproduce the error. Are you using the exact config you posted above?

I'm trying the card in my production environment and not suffering any "page refresh", could you describe this a little more into detail?

Also, could you check how often is the sensor.mqtt_12345_blueiris_front_lower_cam_image_path sensor updating? Maybe update frequency is too high.

luixal commented 10 months ago

Ok, forget about that, using a input_text helper in the template gives me the flickering/refresh efect.

I'll have a look into it.

luixal commented 10 months ago

It was a stupid mistake that made the card update any time the hass object changed. This is, every time any sensor in HA is changed (!!!)

I think it's already fixed, please, try it and let me know.

I just published v0.2.0 and removed v0.1.2, it was a mistake in version numbers.

RJ-Make commented 10 months ago

That fixed it, Thank you!

Happy New Year!