thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.18k stars 111 forks source link

multiple-entity-row name templating #440

Open arifroni opened 2 months ago

arifroni commented 2 months ago

I want to customize the friendly name. But when I use templaing on the name, it doesn't work? is it possible?

type: custom:auto-entities
card:
  type: entities
  title: Heater Reading
filter:
  include:
    - entity_id: sensor.mbus*
      options:
        type: custom:multiple-entity-row
        show_state: false
        secondary_info: last-changed
        entities:
          - attribute: previous_hca
            name: 2023
            unit: m³
          - attribute: current_hca
            name: 2024
            unit: m³
  exclude: []
sort:
  method: state
  ignore_case: false
  numeric: true
  reverse: true

image

as you can see when I just try to use any templating, it fails. I want to remove 'mbus_' and '_heater' from the friendly name and capitalize the rest.

image

ildar170975 commented 2 months ago

Can you see any mentions of templates in Docs? No. Means - templates not supported.

arifroni commented 2 months ago

Can you see any mentions of templates in Docs? No. Means - templates not supported.

I see 1 mention of 'templates'. So I thought it might be possible. image

I saw your other comments as well when I was searching for a solution. They seem a bit rude to be honest, like this one. Do you consider yourself as Linus Torvalds?

Most people ask here because they don't understand or don't know code, like myself. If you are unhappy with these stupid people, just don't bother commenting. Do something useful perhaps.

ildar170975 commented 2 months ago

I see 1 mention of 'templates'. So I thought it might be possible.

For multiple-entity-row? Sorry for wasting your precious time)

Instead of asking how to use the "template" option along with m-e-r (and getting a link to a nice set of solutions), you preferred a hard way of blaming in rudeness.

igorsantos07 commented 2 weeks ago

And then again, the guy with no pic and barely a name is being rude to someone who's not really understanding what's going on, so they can't even properly search stuff as such guy is suggesting.

Fun fact: you KNEW the answer - which is using the terrible templating hack in your link, also found at the never-ending #166 (e.g. the maintainer's idea), issue which you did reference a couple of other times in other duplicates like this one. However, this time you preferred to spit in the OP's face telling them something completely misleading.

ildar170975 commented 2 weeks ago

@igorsantos07

guy with no pic and barely a name

This is a direct insult. What if I say that YOU have no name or your name is meaningless? And this is YOU who is talking about rudeness, palmface.

Arrogance, sick self-loving (in Russian - “больное самолюбие») - here are some of reasons which make you think that you are offended. BTW, as for you particularly - @igorsantos07 - I do recall your name and I definitely helped you in some repos; in THIS particular case you were not involved and yet decided to interfere. Guess you just lost my personal respect.

Oh, forgot about your words about my “terrible templating hack”. My solution is working. It could be non-elegant or not optimal - then people may improve it. But I did share the solution. Do you have a shared list of solutions which people may use as a starting point? Or you prefer blaming other’s solutions?

tsdaemon commented 1 week ago

Hi @arifroni ! I was looking for a similar problem: making auto-entities work with custom:multiple-entity-row. For that, you can't template just part of the filter; you have to rewrite it completely in the template. It can be like this:

type: custom:auto-entities
card:
  type: entities
filter:
  template: |
    [
    {% for state in states.sensor | selectattr('entity_id', 'match', 'sensor.sun') | list -%}
      {{{
          'entity': state.entity_id,
          'type': 'custom:multiple-entity-row',
          'show_state': false,
          'secondary_info': 'last-changed',
          'entities': [{
            'entity': state.entity_id,
            'name': state.name
          }]
      }}},
    {%- endfor %}
    ]
sort:
  method: state
  ignore_case: false
  numeric: true
  reverse: true

I have used the sun sensor as an example, I don't know your use case. Hope this helps!