gadgetchnnel / lovelace-card-templater

Custom Lovelace card which allows Jinja2 templates to be applied to other cards
120 stars 6 forks source link

Filter Entities #56

Open sudoxnym opened 2 years ago

sudoxnym commented 2 years ago

I am attempting to use this with filter entities and I can't get it to work.

  state_filter:
    - string_template: {{ state('sensor.profold_room') }}

should produce Media Room instead, nothing. The only thing that works is your example, which seems kind of pointless unless you just like templating things.

  state_filter:
    - string_template: {{ "Media " + "Room" }}

Works fine, but at that point, I can just write

  state_filter:
    - Media Room

Any help is appreciated. I am ultimately attempting something like this in my template filter:

type: 'custom:card-templater'
card:
  type: entity-filter
  entities:
    - entity: sensor.profold_room
      name: Profold
    - entity: sensor.prowatch_room
      name: Prowatch
    - entity: sensor.bataflip_room
      name: Bataflip
    - entity: sensor.pants_room
      name: Pants
    - entity: sensor.ellie_room
      name: Ellie
    - entity: sensor.lucky_room
      name: Lucky
    - entity: sensor.osiris_room
      name: Osiris
    - entity: sensor.hathor_room
      name: Hathor
  card:
    type: glance
    show_state: false
    show_icon: false
  show_empty: true
  state_filter:
    - string_template: {% if states.sensor.profold_room.state == 'Media Room' %}
                          Media Room
                       {% else %}
                          Somewhere else
                       {% endif %}

No, I don't need to track my pants, that is my cat's name.