isnāt more-info the action by default already?
what happens if you donāt specify that at all?
no, it toogles then
I see, use:
'tap_action':
{'action':'more-info'}
and it shows more-info
btw, its the same behavior using:
- type: custom:auto-entities
filter:
include:
- domain: climate
options:
type: custom:mushroom-climate-card
show_temperature_control: true
layout: horizontal
# required because default action is not what documentation claims
tap_action:
action: more-info
and a bit surprising indeed. should be the default, as documented, and no reason auto-entities would interfere there
fear its a bug in the mushroom-climate card:
- type: custom:mushroom-climate-card
show_temperature_control: true
layout: horizontal
entity: climate.heater_dorm
does not more-info eitherā¦
thanks a lot.
I started without template, but then I couldnāt find out, how to rename. Thatās why I had to go with a template.
yes, the renaming needs another setup, but I figured that wasnt the main point if your question now. got to remember that in those template filters, you simply need to embrace the objects/dicts with braces to keep them together.
read this primer by Thomas: Thomas LovƩn - YAML for Non-programmers
it seems like itās not going to work after all.
Still toggles, and does not show more info.
Here is my code, any mistake?
type: vertical-stack
cards:
- type: custom:mushroom-title-card
title: ''
subtitle: Einstellung
- type: custom:auto-entities
filter:
template: |-
{% for x in states.climate -%}
{{
{
'type': 'custom:mushroom-climate-card',
'show_temperature_control': true,
'layout': 'horizontal',
'entity': x.entity_id,
'name': state_attr(x.entity_id, 'friendly_name')|replace('Thermostat ', ''),
'tap-action':
{'action':'more-info'}
}
}},
{%- endfor %}
show_empty: true
card:
square: false
columns: 1
type: grid
card_param: cards
sort:
method: friendly_name
should be tap_action
:
you can also do:
'tap_action': {'action':'more-info'}
Could you please clarify with example.
I would like to get a dynamic value for sort: count: but no success
Show us your unsuccessful attempt with defining a sort inside the ātemplateā option, weāll try to fix it.
Is there any way to filter two groups at once? How to?
The current value of input_number.auto_entities_sort_count in the Template editor:
{{ states('input_number.auto_entities_sort_count')|int }}
6
sort:
method: state
reverse: true
numeric: true
count: |
template: >
{%- if states('input_number.auto_entities_sort_count')|int == 6 %} 6
{%- elif states('input_number.auto_entities_sort_count')|int == 8 %} 8
{%- elif states('input_number.auto_entities_sort_count')|int == 10 %} 10
{% endif %}
You cannot use a ātemplateā option INSIDE any other option, it must be only inside the āfilterā option.
Yes I know, but I need to change the sort: section and it hasnāt ātempleteā option
So, no options?
You should define a sorted list by using the ātemplateā option.
Something like this:
template: >-
{{ states.switch |
selectattr('state','eq', 'off') |
sort(reverse=true,attribute='name') |
map(attribute='entity_id') | list }}
Sorry, not quite clear, this is not working
filter:
template: >-
{% if states('input_number.auto_entities_sort_count')|int == 4 %}
sort(count='4')
{% elif states('input_number.auto_entities_sort_count')|int == 8 %}
sort(count='8')
{% elif states('input_number.auto_entities_sort_count')|int == 10 %}
sort(count='10')
{% endif %}
check this post, and see how sort is Not contained in the filter template. It can be done.
probably the only way to template the config option for sort, would be by using custom:config-template-card
you then embrace your working auto-entities card, make a variable for the count, and have that set by the config-template-card.
I fear though that is going to be a very demanding card for the Frontend, as it constantly evaluates both the auto-entities, and the new count optionā¦
what Ildar is saying is you can use the jinja template to create a list, but then need to do all manipulation inside that template.
you can add a selector to that template and show only 4:
{{ (states.switch |
selectattr('state','eq', 'off') |
sort(reverse=true,attribute='name') |
map(attribute='entity_id') | list)[:4] }}
ofc, you can then replace the 4 with a templated state of your input_number.auto_entities_sort_count
like:
{% set number = states('input_number.auto_entities_sort_count')|int(default=0) %}
{{ (states.switch |
selectattr('state','eq', 'off') |
sort(reverse=true,attribute='name') |
map(attribute='entity_id') | list)[:number] }}
You may only use jinjia inside templates.
This āsort(count=ā4ā)ā is not smth supported.
https://jinja.palletsprojects.com/en/2.11.x/templates/#sort
As example:
type: vertical-stack
cards:
- type: entities
entities:
- entity: input_boolean.test_boolean
name: reverse sort
- type: custom:auto-entities
card:
type: entities
unique: true
show_empty: true
filter:
template: >-
{% if is_state('input_boolean.test_boolean','on') -%}
{%- set SORT_REVERSE = true -%}
{%- else -%}
{%- set SORT_REVERSE = false -%}
{%- endif -%}
{{
states.switch |
selectattr('state','eq', 'off') |
sort(reverse=SORT_REVERSE,attribute='name') |
map(attribute='entity_id') | list }}
quickly scribbled this together
- type: custom:auto-entities
card:
type: entities
entities:
- input_number.auto_entities_count
filter:
template: >
{% set number = states('input_number.auto_entities_count')|int(default=0) %}
{{ (states.switch |
selectattr('state','eq', 'off') |
sort(reverse=true,attribute='name') |
map(attribute='entity_id') | list)[:number] }}
ofc you can also template the state of the order directly,
- type: custom:auto-entities
card:
type: entities
entities:
- input_number.auto_entities_count
- input_boolean.auto_entities_sort_reverse
- type: divider
filter:
template: >
{% set number = states('input_number.auto_entities_count')|int(default=0) %}
{% set sort = is_state('input_boolean.auto_entities_sort_reverse','on') %}
{{ (states.switch
|selectattr('state','eq', 'off')
|sort(reverse=sort,attribute='name')
|map(attribute='entity_id')
|list)[:number] }}
what ever you want really. As long as it is inside the template and follows jinja rules on list manipulation
Generally works, but not entirely accurate
I donāt think it was the best idea and no way to make it goodly.
sad, that easy count: {{ states(āinput_number.auto_entities_sort_countā)|int }} canāt be used
- type: custom:auto-entities
card:
type: entities
title: Voltage
show_header_toggle: false
filter:
include:
- entity_id: 'sensor.0x*_voltage'
options:
style: |
:host {
--paper-item-icon-color:
{% if states(config.entity)|int < 218 %} #4285F4;
{% elif states(config.entity)|int < 222 %} #0F9D58;
{% elif states(config.entity)|int < 226 %} #F4B400;
{% else %} #DB4437;
{% endif %} }
exclude:
- state: "= 0"
- state: "unavailable"
- state: "None"
template: >-
{% set number = states('input_number.auto_entities_sort_count')|int(default=0) %}
{{ (states.sensor |
selectattr('state','eq', 'off') |
sort(reverse=true,attribute='name') |
map(attribute='entity_id') | list)[:number] }}
show_empty: false
sort:
method: state
reverse: true
numeric: true
Wrong.
Cannot combine ātemplateā with other variants.
Updated: I was wrong