iantrich / config-template-card

šŸ“ Templatable Lovelace Configurations
MIT License
441 stars 56 forks source link

Passed entities inside template #35

Closed DecentM closed 4 years ago

DecentM commented 4 years ago

Is your feature request related to a problem? Please describe. I'm using auto-entities to render a list of my Steam friends based on their online/offline status. The Steam integration now includes the banner image of the game they're playing, and I want those image to show up in HA using multiple picture-element cards.

Since the picture-element card cannot accept a template as the image URL, I'm trying to use config-template-card to wrap it. Auto-entities would pass all my Steam friends to config-template-card, which in turn would pass the image state attribute to picture-elements.

Describe the solution you'd like I'd like to use configuration that looks something like this (emphasis on the "image" line):

type: custom:config-template-card
card:
  type: picture-entity
  title: Currently played games
  image: '${this.entities[0].attributes.some_url}'
entities:
  - sensor.steam_xxxxxxxxxxxxxxxxxxx1
  - sensor.steam_xxxxxxxxxxxxxxxxxxx2
  - sensor.steam_xxxxxxxxxxxxxxxxxxx3

Describe alternatives you've considered I tried using the templated entities fearture, but what I'd like to do is kind of the opposite idea.

Additional context I realise I could specify all my friends in the vars array. The reason I don't want to use variables here is because I already have the list of entities specified elsewhere, so duplicating that list of entities would make the configuration unbearable to maintain.

iantrich commented 4 years ago

Try this._config.entities[0]

DecentM commented 4 years ago

That's exactly what I needed, thank you! šŸŽ‰ I think this is useful enough to have a place in the docs, or even a property on the element for easier access.

If you don't want to use this issue to track that, I'm fine with closing it šŸ…

jack5mikemotown commented 2 years ago

That's exactly what I needed, thank you! šŸŽ‰ I think this is useful enough to have a place in the docs, or even a property on the element for easier access.

If you don't want to use this issue to track that, I'm fine with closing it šŸ…

Id like to echo that it would be extremely helpful to have this in the documentation somewhere.