question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FR: 'options:' doesn't work when I use 'template:' as filter

See original GitHub issue

I’d like to have the possibility to add ‘options:’ to the entities list when I filtered them using a template. For example:

type: custom:auto-entities
card:
  type: entities
  show_header_toggle: false
filter:
  template: |
    {% set temp_map =
     { 'Diesel':'diesel',
       'E10':'e10',
       'Super':'e5' } %}
    {% set state = states('input_select.fuel_type') %}
    {% set sprit = temp_map[state] if state in temp_map %}
    {% for s in states.sensor if 'tankerkoenig' in s.entity_id %}
      {% if (s.attributes.fuel_type == sprit) and not is_state(s.entity_id, 'False') %}
        {{ s.entity_id }}
      {% endif %}
    {% endfor %}
  options:
    name: Test
sort:
  method: state

When I use the syntax with filter: include: ... than options: work fine as expected. But I couldn’t find a way to add ‘options:’ to a template section.

Would be great to have that.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
stefanschaedelicommented, Aug 20, 2022

This is my current

filter:
  template: >-
    {% set matcher = 'input_boolean.chore_[0-9]+_.*' ~ (now().strftime('%a') | lower) -%}
    {%- for bool in states.input_boolean -%}
      {%- if bool.entity_id is match(matcher) -%}
        {{
          {
            'entity': bool.entity_id,
            'tap_action': {
              'action': 'toggle'
            }
          }
        }},
      {%- endif -%}
    {%- endfor %}

This would be much nicer, in my opinion. But not necessary.

filter:
  options:
    tap_action:
      action: 'toggle'
  template: >-
    {% set matcher = 'input_boolean.chore_[0-9]+_.*' ~ (now().strftime('%a') | lower) -%}
    {%- for bool in states.input_boolean -%}
      {%- if bool.entity_id is match(matcher) -%}
        {{ bool.entity_id }},
      {%- endif -%}
    {%- endfor %}

fully agree with this, I have exactly the same case…

1reaction
beauwestcommented, Jul 27, 2022

This is my current

filter:
  template: >-
    {% set matcher = 'input_boolean.chore_[0-9]+_.*' ~ (now().strftime('%a') | lower) -%}
    {%- for bool in states.input_boolean -%}
      {%- if bool.entity_id is match(matcher) -%}
        {{
          {
            'entity': bool.entity_id,
            'tap_action': {
              'action': 'toggle'
            }
          }
        }},
      {%- endif -%}
    {%- endfor %}

This would be much nicer, in my opinion. But not necessary.

filter:
  options:
    tap_action:
      action: 'toggle'
  template: >-
    {% set matcher = 'input_boolean.chore_[0-9]+_.*' ~ (now().strftime('%a') | lower) -%}
    {%- for bool in states.input_boolean -%}
      {%- if bool.entity_id is match(matcher) -%}
        {{ bool.entity_id }},
      {%- endif -%}
    {%- endfor %}
Read more comments on GitHub >

github_iconTop Results From Across the Web

JetSmartFilters Not Working: 7 Things You Need to Check
In this troubleshooting article, you will find solutions to the 7 most common issues why JetSmartFilters may not be working.
Read more >
Filter data in a range or table - Microsoft Support
Use filters to temporarily hide some of the data in a table, so you can focus on the data you want to see....
Read more >
How do I perform query filtering in django templates
The easiest is to do the filtering, then pass the result to ... to templates that you are working on, but use Django's...
Read more >
Built-in template tags and filters - Django documentation
This document describes Django's built-in template tags and filters. It is recommended that you use the automatic documentation, if available, ...
Read more >
Edit List View Filters in Lightning Experience - Salesforce Help
The filter logic statement can't reference a filter number that doesn't exist. Note NOT doesn't work with parenthetical expressions. For example, the expression ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found