lovelace-auto-entities: FR: 'options:' doesn't work when I use 'template:' as filter

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.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (2 by maintainers)

Most upvoted comments

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…

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 %}

It would be really nice to be able to use options: with template:. I think that the workaround above would work in my current scenario, but it’d just be simpler if the existing feature worked.