#Picture entity not working with template

1 messages · Page 1 of 1 (latest)

weary abyss
#

Heya, I am trying to get my album art in a picture entity, but I am having trouble with an template thingy to try to cache bust so that it loads new images

Underneath is my YAML

show_name: true
fit_mode: cover
type: picture-entity
entity: media_player.home
state_image:
  playing: '/api/media_player_proxy/media_player.home?token=mytokengoeshere&cache={{ now().strftime("%Y%m%d%H%M%S") }}'

According to the documentation I should be able to punch in template values into the YAML like I am doing since it shows it in the examples as well.

Currently trying it with dates, but I plan to have some more rapidly changing values in there if the card allows for it

weary abyss
#

The massive picture (duh) is not adhering to the template I try to set and when I look in inspect element I see the URL of the state_image.playing from the YAML config

idle adder
#

You can't use templates in frontend cards.
(except markdown)

weary abyss
#

🙁

#

But I saw in the documentation that the photo entity had an template in the examples

idle adder
#

So the frontend doesn't process/resolve that template at all, it just sends that string to the camera.snapshot action. I guess the camera action might handle it, but that's pretty nonstandard.

#

In general you can't template anything in the frontend.

weary abyss
#

Aaaaah

#

Got it

#

Maybe I can write a little javascript to handle my very very niche usecase

idle adder
#

Are you just trying to display the entity_picture?

weary abyss
#

Yes

#

Trying to show the album art of my media player

idle adder
#

I imagine we can probably just make this work natively, we already show the entity_picture for person entity in this card, but it's hardcoded to only that domain...

weary abyss
#

I see

#

That would be amazing though

idle adder
#

Although I guess sometimes it doesn't have an entity picture if it's not playing

weary abyss
#

Thats true, but for that the media entity can have a fallback?

#

So its a bit more involved than only adding the media_player domain to the picture entity/card

idle adder
#

Hmm, yeah not sure if it's worth that.

#

Maybe a template image entity can get you somewhere 🤔

weary abyss
#

I was thinking about that too yea

idle adder
#

That's sort of a way to combine templates & frontend image cards

weary abyss
#

I'll play around for a while with it

idle adder
#

There's also media player card

weary abyss
#

I've been using that for volume control

#

But I wanted to build a dashboard to control my speakers and I wanted a challenge

idle adder
#

Template image kind of got me there. You need to manually add the host part of the url which is annoying.

#

{{ state_attr('media_player.bedroom', 'entity_picture') }}

#

You could code a fallback image there of your choosing as well

weary abyss
#

The URL is fine

#

But dude, holy sh*t. Thanks!

idle adder
#

oh actually nevermind, you don't need that

weary abyss
#

Never thought of going with an helper

idle adder
#

just the state attr seems to work with the relative path

weary abyss
#

it does yea

idle adder
#

TIL

weary abyss
#

This is amazing

#

I learned something about the template image helper today

idle adder
#

Yeah it seems to rarely be mentioned

weary abyss
#

I've been doing a lot with the input_select lately but the image slipped my mind since i never clicked into that menu

#

and its instant update too

#

exactly what i've been looking for

#

Especially Music Assistant is providing the images so only one call to the internet needs to be made for it 🙂