thomasloven / lovelace-template-entity-row

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

FR: support for templating on Unit #33

Closed Mariusthvdb closed 3 years ago

Mariusthvdb commented 3 years ago

Would be really nice if we could further refine the frontend using the templates in your card, by adding support for the Unit field, eg:

            type: custom:template-entity-row
            state: >
              {{states(config.entity)}}
            secondary: >
              {{state_attr(config.entity,'date')}}
            unit: >
              {{'Day' if state_attr(config.entity,'days') == '1' else 'Days'}}

thanks for considering !

thomasloven commented 3 years ago

What's the difference from

state: {{ states(config.entity) }} {{'Day' if state_attr(config.entity, 'days') == '1' else 'Days'}}

?

Mariusthvdb commented 3 years ago

Not sure ;-) Guess put like your template, we 'fake' a State and Unit into 1 line, while separating like in mine, we adhere to the HA usage of state and unit_of_measurement ?

thomasloven commented 3 years ago

I think this adds unnecessary complexity. The difference between value and unit doesn't matter because this is purely for display purposes.