thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
210 stars 16 forks source link

Feature request: var with entity #37

Closed jesperldk closed 3 years ago

jesperldk commented 3 years ago

When using auto-entities, it would be really nice if template-entity-row somehow could reference the current entity in jinja. As an example, it would allow me to show a specific attribute from the entity as secondary.

thomasloven commented 3 years ago

{{ config.entity_id }}

jesperldk commented 3 years ago

I couldn't really find any docu on this, but by experimenting a bit, it seems like config.entity holds the name of the entity, but I could not figure out what config.entity_id is.

Anyway, I can now do:

 type: custom:template-entity-row
   state: "{{ state_attr( config.entity, 'message' ) }}"
   secondary: "{{ relative_time( states[config.entity].last_updated ) }}"

And is very happy :-)

edit: well, relative_time( states[config.entity].last_updated ) does not update (of course), and does not make sense :-(

thomasloven commented 3 years ago

Yes, you're right. It's config.entity. Sorry.

Auto-entities sets entity: of each item configuration, and config is mentioned in the template-entity-row readme.