Using templates on cards. Help needed!

Hi all,

I am trying to setup a card which shows me commute time.

I want to choose what to show

  • from Home to Work :house: ❯-❯-❯ :office:
  • from Work to Home :house: ❮-❮-❮ :office:

So, I created an input_select to choose which direction to show: Home or Work.

How can I use templates to choose which entity to show?

I have tried with this configuration:

- type: vertical-stack
  cards:
    - type: entities
      entities:
        - entity: input_select.destination
    - type: 'custom:travel-time-card'
      entities:
        - entity: >
            {%  if is_state("input_select.destination", "Home")
            %}"sensor.work_home_travel_time" {% elif
            is_state("input_select.destination", "Work")
            %}"sensor.home_work_travel_time" {% endif %}

but It does not work as expected.

templates don’t work everywhere. The card needs to support templates for templates to work. This card does not support templates.

You can get a custom template card and combine that with the travel time card.

Also, your template won’t work. It should look like this (I made it look pretty, but you had a quoting error that was removed):

            {%  if is_state("input_select.destination", "Home") %}
              sensor.work_home_travel_time
            {% elif is_state("input_select.destination", "Work") %}
              sensor.home_work_travel_time
            {% endif %}