🔹 template-entity-row - Put templates in an entities row

Hi all,
im kind of stuck, any idea why this would not work?

type: entities
entities:
  - entity: sensor.vidya_vox
    tap_action:
      action: call-service
      service: androidtv.adb_command
      service_data:
        entity_id: media_player.android_tv_192_168_178_134
        command: >-
          am start -a android.intent.action.VIEW
          {{states('sensor.youtube_vidya_vox_url') }} 
  - entity: sensor.undecided_with_matt_ferrell
    tap_action:
      action: call-service
      service: androidtv.adb_command
      service_data:
        entity_id: media_player.android_tv_192_168_178_134
        command: >-
          am start -a android.intent.action.VIEW
          {{states('sensor.youtube_undecided_mf_url') }}
  - entity: sensor.home_assistant
    tap_action:
      action: call-service
      service: androidtv.adb_command
      service_data:
        entity_id: media_player.android_tv_192_168_178_134
        command: >-
          am start -a android.intent.action.VIEW
          {{states('sensor.youtube_homeassitant_youtube_url') }}
  - entity: sensor.mr_nightmare
    tap_action:
      action: call-service
      service: androidtv.adb_command
      service_data:
        entity_id: media_player.android_tv_192_168_178_134
        command: >-
          am start -a android.intent.action.VIEW
          {{states('sensor.youtube_mr_nightmare_video_url') }}
  - entity: sensor.lindsey_stirling
    tap_action:
      action: call-service
      service: androidtv.adb_command
      service_data:
        entity_id: media_player.android_tv_192_168_178_134
        command: >-
          am start -a android.intent.action.VIEW
          {{states('sensor.youtube_lindsey_stirling_url') }}
show_header_toggle: false
title: Youtube Channels Latest


While this does:

Thanls all for your comments!

well made it work with scripts:

alias: Play YouTube channel Home Assistant
sequence:
  - service: androidtv.adb_command
    data:
      command: " am start -a android.intent.action.VIEW {{states('sensor.youtube_homeassitant_youtube_url') }} "
    target:
      entity_id: media_player.android_tv_192_168_178_134
mode: single
icon: mdi:youtube

Thanks very much for this useful enhancement. I’m using it for my air conditioning zones to show the temperature as secondary information.

Is it possible to get the more-info action to actually show the history of a different entity?

For example, when I click on these entries I’d like to see a history of the temperature, rather than history of the on/off for the zone.

image

Each row here is currently defined like:

  - type: custom:template-entity-row
    entity: switch.daikin_ac_study
    icon: mdi:air-filter
    name: Study
    toggle: true
    secondary: >
      {% if ((as_timestamp(now()) -
      as_timestamp(states.sensor.study_sensor_temperature.last_changed)) ) <
      3600 -%}
        Temp: {{ states( 'sensor.study_sensor_temperature' ) }}c
      {%- else -%}
        Temp: n/a
      {%- endif %}

did you check the action options:

Hi Ildar_Gabdullin,

I am interested in multiline support! I changed the master.ts file by inserting

        #wrapper .info.pointer .secondary {
          white-space: pre;
        }   

I restarted the HA server and created a card:

type: entities
entities:
  - entity: sensor.victron_mqtt_shutdown_signal
    secondary: |
      {% if states('sensor.victron_mqtt_shutdown_signal') == '6' %} 
        Running since

        {{ as_timestamp(states[config.entity].last_changed)| timestamp_custom('%d %b, %Y - %X') }}
      {% else %} 
         {% if states('sensor.victron_mqtt_shutdown_signal') == '7' %}
                  VenusOS received BMB shutdown signal on  {{ as_timestamp(states[config.entity].last_changed)| timestamp_custom('%d %b, %Y - %X') }}
         {% endif %} 
      {% endif %}
    type: custom:template-entity-row

The result is not what I expected, the output is single-line without line break. Is there something wrong in my yaml code?

Richard

I do not have access to my PC, cannot say for sure - but try using “\A” as a line break.

Here I did not use it; so, try playing with this too:

  • remove extra “enter” after the 1st line;
  • use “-%}” instead of “%}”.

Thanks for your suggestions. I am still doing something wrong, because installing the card-mod and adding the style: code does work (like the example you referred to).

It seems to be that the changes I’ve made in main.ts (in /www/lovelace-template-entity-row/src) do not have any effect. What I did was:

nano /www/lovelace-template-entity-row/src/main.ts

and inserted your lines between #wrapper.hidden and #staging, like this:

        #wrapper.hidden {
          display: none;
        }
        #wrapper .info.pointer .secondary {
          white-space: pre;
        }       
        #staging {
          display: none;
        }

I saved the main.ts file and restarted HA. Am I missing someting? Is there more to do to make it work? I am not very familiar working with resources…

I am afraid only the Author may help you…
I myself using the “official” (untouched) plugin.

Btw, go to Code inspector and check if the added style is actually added.

I guess I don’t understand completely how to use github. I want to work with the untouched version as well, I just wanted to test your suggestions. I will return to the original version and use the card-mod for now. Thanx for your help!

I think the result file must be js.
You are supposed to compile your changed project into one js file.

Hi all

how is it possible to show last-updated as secondary: in a template-entity-row card ?

I’ve tried like this, but it doesn’t work

type: custom:template-entity-row
icon: mdi:car
name: "Waze route is {{state_attr('sensor.work','route')}}"
state: "{{states('sensor.work')}} min"
secondary: "{{ relative_time( states[config.entity].last_updated) }}"

Any suggestion?

Thanks

Hi all,
I’m just trying to populate image: with an attribute value, but it fails:

type: entities
entities:
  - type: custom:template-entity-row
    entity: sensor.billigste_stasjon
    image: {{ state_attr('sensor.billigste_stasjon', 'pictureurl') }}

title: Drivstoffpriser

If I type the pictureurl manually, it works just fine:

image

I have tried all possible combinations of single and double quotes without any luck.
Is it possible to customize the card image using template-entity-row at all??

Try your template in Dev tools → Template first. Your template is wrong.

Thanks @Ildar_Gabdullin for your reply.
It was just a typo. I’ve tried so many things - I got somewhat carried away.
I’ve corrected the typo now, but it still doesn’t work. However, in Dev tools Template, it works ok:

Try this:

image: “{{ ... }}”

instead

image: {{ ... }}
1 Like

Indeed - that works. Thank you so much :+1:

1 Like

I am trying to use the ‘active’ option to have the icon color change. But the icon color never changes. Even if I add “active: true” or “active: false”, makes no difference in icon color. Any ideas?

  - entity: number.pool_flow_sensor
    type: custom:template-entity-row
    state: |
      {% if states.number.pool_flow_sensor.state == '1' %}
        On
      {% elif states.number.pool_flow_sensor.state == '0' %}
        Off
      {% endif %}    
    active: "{{ is_state('number.pool_flow_sensor', '1') }}"
    name: Flow Sensor
    icon: mdi:waves-arrow-right

you have 2 quotes at the end of the active: line- should only be 1.

Thanks, 35e, for looking it over. That was just a typo of mine when copying it here.

But I did find the issue! I had to remove the “entity: number.pool_flow_sensor” line. Having the number entity listed caused the icon color not to change. Once I deleted that line, it is working fine!

  - type: custom:template-entity-row
    state: |
      {% if states.number.pool_flow_sensor.state == '1' %}
        On
      {% elif states.number.pool_flow_sensor.state == '0' %}
        Off
      {% endif %}    
    active: '{{ states.number.pool_flow_sensor.state == ''1'' }}'
    name: Flow Sensor
    icon: mdi:waves-arrow-right

EDIT: after more testing, I have found that number entities are all impacted by this issue. Sensor entities work just fine. The downside of not being able to include the entity definition is that history cannot be access by clicking on the icon.

@thomasloven, is this by design? Is there a way that number entities can be allowed?