šŸ”¹ template-entity-row - Put templates in an entities row

Ok.
Iā€™ll have a fix up later today.

Temporary workaround: add

entity_ids:
  - binary_sensor.pir_...
1 Like

Hi Thomas,

would you add the tap/hold action functionality also? Would be really very nice indeed.

Thatā€™s very kind of you, thanks!
Just a thought:
I only need to re-define state because (I think) standard LL entity row looks at my binary_sensorā€™s device_class and internally does that off ā†’ Clear/on ā†’ Detected substitution so I donā€™t see those off/on if I use standard entity row. Maybe your code could do the same?
That way there will be less template processing and generally room for error :wink:

On a similar note, I have activeā€¦ but itā€™s much trickier considering the recent state of things with dropping colour changes in standard cards.

I just wanted to update my report based on some observation.
Your workaround let me see immediate changes in state but as my secondary info displays time elapsed from the last on state in needs to be updated regularly.
So I ended up having this and it works better as being updated both upon state change and then every minute

entity_ids:
      - binary_sensor.pir_ground_floor_lounge
      - sensor.time

Donā€™t know if there is a better way of doing what I want thoughā€¦

Just wanted to say a big thank you for the fix - I downloaded the latest version and it works for me without entity_ids (even without sensor.time - good stuff).
You donā€™t do releases of it, do you? :wink:

@thomasloven I have an issue similar to the previous one when using condition as I want to hide my input_number when an automation is disabled - my card is updated only if I refresh the page.
Hereā€™s the simple config

type: entities
show_header_toggle: false
title: Ventilation
entities:
  - entity: automation.ventilation_1st_floor_bathroom_extractor_fan_turn_on_by_humdity_threshold

  - type: custom:template-entity-row
    entity: input_number.ventilation_1st_floor_bathroom_shower_humidity_threshold
    condition: >
      {{ is_state('automation.ventilation_1st_floor_bathroom_extractor_fan_turn_on_by_humdity_threshold', 'on') }}

The workaround works, too :wink:

But there is another problem - that input_number (mode: slider, but mode: box makes no difference) behaves like a sensor so I can see no box around it and cannot change its value.
Could you look into it please?

@thomasloven

I recently learned that it is considered normal for template-entity-row to momentarily display its raw templates during a page-refresh (this may be true of other custom cards as well; I donā€™t know because I donā€™t use any others).
Template-Entity-Row momentarily displays its templates

My point of reference is Custom UI and its templates are never displayed in the UI. Can you explain to a novice like me how Custom UI and template-entity-row differ in their approach?

FWIW, Iā€™m trying to replace Custom UI with purely Lovelace cards and techniques. My requirement is fairly simple: I want to change the icon (and its color) of an entities card based on the entityā€™s state. Iā€™m using style: to set the iconā€™s color and template-entity-row to set the icon. It produces the same appearance as Custom UI but has the additional undesirable feature of showing its templates during rendering.

For the benefit of other readers, this issue was resolved here.

1 Like

I chose to display the original template as a fallback. That means that if the template fails to evaluate for any reason, you will be able to at least see it and possibly find out what went wrong.

That also means that on initial load, you will see the template until the backend can evaluate it and send the result back to the frontend.

Thank you for the explanation.

If I understood you correctly, you are saying the template is displayed by design. In other words, it is entirely feasible to not momentarily display the template but it was decided to display it.

I ask that you reconsider this design choice (or provide an option to enable/disable the display of templates). Hereā€™s why:

  1. From the standpoint of aesthetics, itā€™s unattractive. I canā€™t recall seeing any web page that, when refreshed, momentarily reveals portions of its raw code prior to rendering it.
  2. If the template has an error, I doubt seeing it flash on the screen for a half-second allows anyone to analyze it.

yes, + 1 to that indeed.
We have to write correct templates, and have guards to prevent unknownā€™sā€¦

if anything, an error could be logged stating the template is incorrect. If possible at all, drop the initial momentarily display, and show the evaluated result immediately.

hi Thomas,

please let me ask your assistance in rewriting some secondaryinfo-entity-rowā€™s to your template-entity-row. I have this:

  - type: custom:stack-in-card
    title: Boiler switch monitor
    cards:
      - type: entities
        show_header_toggle: false
        entities:
          - type: 'custom:secondaryinfo-entity-row'
            entity: switch.sw_boiler_bijkeuken_sc
            state_color: true
            secondary_info: 'Actueel verbruik: [[ sensor.boiler_bijkeuken_actueel ]] watt'

          - type: custom:template-entity-row
            entity: switch.sw_boiler_bijkeuken_sc
            active: >
              {{is_state(config.entity,'on')}}
#            state_color: true
            secondary: >
              Actueel verbruik: {{states('sensor.boiler_bijkeuken_actueel')}} watt

showing like:

I have 2 questions in particular:

  • would you consider adding support for state_color? As you can see I know we can use a template there, but as state_color is used in core HA, it might be a valuable addition, and make the config just that bit simpler (and not have to evaluate a jinja template could be beneficial to the system.)

  • can we have the toggle for a switch, instead of the value for state? dont think I found it in your docā€™s. If no yet possible, would you consider adding that too please?

Thanks for considering!

2 Likes

+1 Only just started using thisā€¦ replaced secondaryinfo-entity-row and card tools with it and that was the first thing I noticed as well.

1 Like

hey David, Maybe also +1 on the Fr for the toggle :wink:

1 Like

Is it possible for the secondary info to have multi line output? I canā€™t seem to inject any kind of of new line character in the template.

anyone else seeing issues on the template-entity-row card in HA115.
I am using this on templates built by Python at startup, which apparently is not very well digested (too late for the engine, causing the full startup to take a very long time.) either by HA, or by the T-e-r card.

thereā€™s a fix for HA planned for several of these timing issues, maybe T-e-r card would need some extra attention

Iā€™m trying to get template-entity-row to show localized state which in my case I think should be like this:

state: "_(state.binary_sensor.door.{{states('binary_sensor.balkongdorr_sovrum_tmpl')}})"

which shows up like this:
image

ā€¦not really the way I expected.

But this actually works:

state: "_(component.binary_sensor.state.door.{{states('binary_sensor.balkongdorr_sovrum_tmpl')}})"

image

Am I doing something wrong (that just accidentally happened to work) or has something changed and the docs should be updated?

having made this verbose template:

  - type: custom:auto-entities
    card:
      type: entities
      title: Person address trackers
    filter:
      include:
        - entity_id: person.*_address
          options:
            type: custom:template-entity-row
            secondary: >
              {{state_attr(config.entity,'road')}} {{state_attr(config.entity,'house_number')}},{{state_attr(config.entity,'postcode')}} {{state_attr(config.entity,'town') if state_attr(config.entity,'town') else state_attr(config.entity,'city')}}, {{state_attr(config.entity,'country')}}

I suppose there could be a better wayā€¦
but, donā€™t see it right now, so turning to the community here.

Please have a look? thanks!

Is this HACS add-in still working?

I just get ā€˜custom element doesnā€™t exist: template-entity-rowā€™

Iā€™ve installed it using up-to-date HACS (1.9.0) whilst running 2020-12-1 and also restarted HA.

I am using it with no problems

Maybe it is the act of installing it in the current HA version.??
I got round it by using card-templater instead.