uups, sorry! But is it also possible to use an attribute instead of friendly_name
on the left side? Or alternatively, to create a sensor whose friendly_name
is created via a template?
Probably possible by using a “template” option based on examples in the thread.
Where could a template be inserted? Under options? I mean:
options:
name:
...
OK, I modified the sensor - it’s possible to template the friendly_name:
friendly_name: "Test {{ states('sensor.klimasensor_1_humidity') | float(default=0) }}"
Hi, I had this code working before and I liked how it looked in the UI:
type: custom:auto-entities
card:
type: vertical-stack
card_param: cards
filter:
include:
- entity_id: light.*
state: 'on'
options:
type: custom:mushroom-update-card
entities:
- this.entity_id
tap_action:
action: call-service
service: homeassistant.turn_off
service_data:
entity_id: this.entity_id
Now I have a template that obtain all the lights and switches that I want to display. But I have lost the ability to display these “lights” with a mushroom card.
type: custom:auto-entities
card:
type: entities
filter:
template: >-
{{ expand('group.Lights_House') | selectattr('state','eq','on') |
map(attribute='entity_id') | list }}
Any ideas on how to make it look better (maybe like before) using the template in filter?
type: custom:auto-entities
card:
type: grid
title: Group
card_param: cards
filter:
include:
- group: group.Lights_House
state: 'on'
options:
type: custom:mushroom-entity-card
primary_info: state
secondary_info: name
layout: vertical
Thank you for your answer. That does not work for me. I assume is because of group.Lights_House is a group that contains other groups
In this case use a for
loop:
type: custom:auto-entities
card:
type: grid
columns: 5
square: false
title: Template
card_param: cards
filter:
template: |-
{% for x in expand('group.Lights_House') | selectattr('state','eq','on') %}
{{- {
'type': 'custom:mushroom-entity-card',
'entity': x.entity_id,
'primary_info': 'state',
'secondary_info': 'name',
'vertical': true }
-}},{%- endfor -%}
Great, they are now visible. But is there any way to keep the tap_action ?
Sure:
type: custom:auto-entities
card:
type: grid
columns: 3
square: false
title: Template
card_param: cards
filter:
template: |-
{% for x in expand('group.Lights_House') | selectattr('state','eq','on') %}
{{-
{
'type': 'custom:mushroom-entity-card',
'entity': x.entity_id,
'primary_info': 'state',
'secondary_info': 'name',
'vertical': true,
'tap_action': {
'action': 'call-service',
'service': 'homeassistant.turn_off',
'target': { 'entity_id': x.entity_id }
}
}
-}},{%- endfor -%}
It worked great! I don’t know how you can do all this! I understand the script, but man … you are a genius!
Is it possible to specified a time condition like for example if it is between 9pm and 7am, show me covers left open ?
Thanks.
Hi
I’m trying to use this example but I get an error ‘No card type configured’
card:
- type: custom:auto-entities
card:
type: vertical-stack
card_param: cards
filter:
template: >
{% for l in states.light
|selectattr('attributes.is_hue_group','defined')
|selectattr('attributes.is_hue_group','eq',true)
|list -%}
{{
{
'type': 'custom:button-card',
'entity': l.entity_id,
'name': l.name,
'template': 'hue_scenes'
}
}},
{%- endfor %}
Trying to generate a vertical stack of custom-button cards for all Hue rooms.
The template works in the developers tools.
Grateful for any advice.
Thanks
Andy
What is the first line “card”?
And why the 2nd line starts with ”-“?
Apologies. Here is the whole thing:
title: Coloured Light Scenes
icon: mdi:lamps
cards:
- type: custom:button-card
template: container
color: "#808080"
name: Lights
custom_fields:
buttons:
card:
- type: custom:auto-entities
card:
type: vertical-stack
card_param: cards
filter:
template: >
{% for l in states.light
|selectattr('attributes.is_hue_group','defined')
|selectattr('attributes.is_hue_group','eq',true)
|list -%}
{{
{
'type': 'custom:button-card',
'entity': l.entity_id,
'name': l.name,
'template': 'hue_scenes'
}
}},
{%- endfor %}
You’re right - removing the ‘-’ fixes it. Sometimes can’t see the wood for the trees!!
Many thanks
Andy
Create a card starting from this line and see if it works.
If yes - then the problem is in the upper code.
I do not think this is correct:
since the “card” option is NOT a list.
I’m using the auto-entities for warning me about updates on my dashboard, but I want one thing changed.
I want entity “binary_sensor.docker_hub_update_available” to only show if the entity “sensor.docker_hub” is not ending on “.0”.
The regex for that is regex_search('[^0]$')
But i do not manage to create a filter on the auto-entities.
Somebody knows how to succeed?
I’m using this as my card code:
card:
show_header_toggle: false
title: Updates
type: entities
filter:
exclude: []
include:
- entity_id: binary_sensor.*update*
state: 'on'
- domain: update
state: 'on'
show_empty: false
sort:
numeric: true
type: custom:auto-entities
Hi
How can I refer to a parent/base entity in the template of a auto-entities
card??
I have a custom-button
template:
hue_scenes:
show_icon: false
styles:
card:
- padding: 0
- background-color: inherit
- border-radius: 4px
name:
- font-size: 0.8em
- white-space: normal
- color: white
- justify-self: start
grid:
- grid-template-areas: '"n buttons"'
- grid-template-columns: 1fr 1fr
- grid-template-rows: 1fr
custom_fields:
buttons:
- padding: 0
- margin: 0
card_mod:
style: |
ha-card { border-width: 0px; pointer-events: none; }
custom_fields:
buttons:
card:
type: custom:auto-entities
card:
type: horizontal-stack
card_param: cards
filter:
template: >
{% for s in state_attr(entity.entity_id, 'hue_scenes') -%}
{{
{
'type': 'button',
'show_state': 'false',
'icon': 'mdi-lightbulb',
'name': s
}
}},
{%- endfor %}
It is referred to by (from the discussion above)
title: Coloured Light Scenes
icon: mdi:lamps
cards:
- type: custom:button-card
template: container
color: "#808080"
name: Lights
custom_fields:
buttons:
card:
type: custom:auto-entities
card:
type: vertical-stack
card_param: cards
filter:
template: >
{% for l in states.light
|selectattr('attributes.is_hue_group','defined')
|selectattr('attributes.is_hue_group','eq',true)
|list -%}
{{
{
'type': 'custom:button-card',
'entity': l.entity_id,
'name': l.name,
'template': 'hue_scenes'
}
}},
{%- endfor %}
The second piece of code works fine.
If I change entity.entity_id in the top piece of code for any specific entity like light.dining_room
it works fine (although obvously displays the same cards for each room).
What is the correct way to refer to the base entitty in an auto-entities card??
Thanks
Andy
Help please.
Hi jeremypsl,
I’m new to this but does this help??
{% if now().hour >= 21 or now().hour <=6 %}
{% for s in states.cover|selectattr('state','eq','open') -%}
{{
{
'name': s.entity_id
}
}},
{%- endfor %}
{% endif %}