I will try that. Thx.
Maybe a stupid question, but this is written in jinja2 language?
And do you now some good sites to learn this? or examples?
Thx. a lot
Example with "template"
filter - a list of devices with battery level <= WARNING_LEVEL.
- Icon’s color is managed by card-mod, the
"style"
property is passed to"template"
. - Value of WARNING_LEVEL is managed by slider &
"input_select"
. - A hyperlink to a view with a whole devices’ list is provided.
- Card-mod is also used for removing padding, word wrapping for the slider.
Note: translation from Russian to English is inside comments.
type: 'custom:stack-in-card'
mode: vertical
keep:
background: false
box_shadow: false
margin: false
outer_padding: false
border_radius: false
cards:
- type: 'custom:auto-entities'
card:
type: entities
title: Контроль заряда батарей ### Battery level check
entities:
- type: section
label: Список устройств ### Devices
unique: false
show_empty: true
filter:
template: >
{% set WARNING_LEVEL = states('input_number.battery_level_check') |
float -%}
{%- for state in states.sensor -%}
{%- if state.entity_id | regex_match('sensor.battery_',ignorecase=False) -%}
{%- set LEVEL = states(state.entity_id) | float -%}
{%- if LEVEL <= WARNING_LEVEL -%}
{{
{ 'entity': state.entity_id,
'secondary_info': 'last-changed',
'style': ':host { {%- if states(config.entity) == "unknown" -%}
--paper-item-icon-color: brown;
{%- elif states(config.entity) | float <= states("input_number.battery_level_critical") | float -%}
--paper-item-icon-color: red;
{%- elif states(config.entity) | float <= states("input_number.battery_level_warning") | float -%}
--paper-item-icon-color: rgb(250,218,67);
{%- else -%}
--paper-item-icon-color: green;
{%- endif %} }'
} }},
{%- endif -%}
{%- endif -%}
{%- endfor %}
sort:
method: state
reverse: false
ignore_case: false
attribute: null
first: 0
count: 1000
numeric: true
- type: entities
entities:
- type: button
icon: 'mdi:blank'
name: ' '
action_name: Полный список устройств ### All devices
tap_action:
action: navigate
navigation_path: /lovelace/battery
style: |
ha-card .card-content {
padding-top: 0px;
padding-bottom: 0px;
}
- type: entities
entities:
- type: section
- type: 'custom:fold-entity-row'
head:
type: 'custom:dummy-entity-row'
entity: sensor.test_zero_value
icon: 'mdi:cogs'
name: Настройки ## Settings
padding: 0
open: false
entities:
- type: divider
style:
height: 10px
width: 100%
background: none
- entity: input_number.battery_level_check
name: 'Уровень заряда менее, чем' ### Level less than
style:
hui-generic-entity-row:
$: |
.info.text-content {
text-overflow: unset !important;
white-space: unset !important;
}
Thx. It seems to work.
maybe have a look in the dedicated thread for afvalwijzer: Garbage pickup date (mijnafvalwijzer.nl) custom_component
the template I posted there isnt doing what you ask, but you might see useful info for having auto generated cards with this integration.
Also, glad to assist getting you up and running, but hop over there and will see what you need.
I will look in that thread for afvalwijzer.
Does anyone know if it is possible to use auto entities to break out and create a card for each item in a list attribute of a single entity?
I’ve looked around and not had any luck so far, any help appreciated.
I figured out how to get it to create entities for the attributes using the template filter but I’m still stuck on how I can get this to work with the card_param so the buttons can be added to a grid card.
This is what I have so far…
> type: 'custom:auto-entities'
> show_empty: true
> card:
> type: grid
> columns: 3
> card_param: cards
> filter:
> template: |
> {%- for chore in state_attr('sensor.grocy_chores', 'chores') -%}
> {{ { 'entity' : 'sensor.grocy_chores',
> 'name' : chore.name,
> 'icon' : 'mdi:fish',
> 'type' : 'custom:button-card',
> }
> }},
> {%- endfor -%}
I’m not getting anything to populate with your example. I verified that my grocy chores sensor is the same. Could you verify the formatting? I also tried different types of cards in type and I get no output at all.
type: 'custom:auto-entities'
show_empty: true
card:
type: grid
columns: 3
card_param: cards
filter:
template: |
{%- for chore in state_attr('sensor.grocy_chores', 'chores') -%}
{{ { 'entity' : 'sensor.grocy_chores',
'name' : chore.name,
'icon' : 'mdi:fish',
'type' : 'custom:button-card',
}
}},
{%- endfor -%}
Thanks for the help, that is the problem I can get it to work adding it simply to the entities card but I can’t get the template filter working with a card that expects “cards” as input.
The below does work but I want more control over the layout of the buttons
type: 'custom:auto-entities'
show_empty: true
card:
type: entities
filter:
template: |
{%- for chore in state_attr('sensor.grocy_chores', 'chores') -%}
{{ { 'entity' : 'sensor.grocy_chores',
'name' : chore.name,
'icon' : 'mdi:fish',
'type' : 'custom:button-card',
}
}},
{%- endfor -%}
The type you are using for the template is actually ‘special row elements’, at least that is how it is working for me.
https://www.home-assistant.io/lovelace/entities/
type: 'custom:auto-entities'
show_empty: true
card:
type: entities
filter:
template: |
{%- for chore in state_attr('sensor.grocy_chores', 'chores') -%}
{{ { 'entity' : 'sensor.grocy_chores',
'name' : chore.name,
'icon' : 'mdi:broom',
'type' : 'button',
}
}},
{%- endfor -%}
Hi Marius,
Maybe you can help me. The auto-entities in the glance card works how I want it.
But, with the auto-entities I don’t now how to show the image instead of the standard icon.
Can you help me?
please post a config and a sensor you want to show an image for. My guess is, you want to customize the sensor using an image instead of the icon. if that’s the case, you need something like this:
homeassistant:
customize:
sensor.afvalwijzer_restafval:
entity_picture: /local/afvalwijzer/restafval_saver.png
friendly_name: Restafval
sensor.afvalwijzer_plastic:
entity_picture: /local/afvalwijzer/plastic_saver.png
friendly_name: Plastic
sensor.afvalwijzer_gft:
entity_picture: /local/afvalwijzer/gft_saver.png
friendly_name: Gft
sensor.afvalwijzer_papier:
entity_picture: /local/afvalwijzer/papier_saver.png
friendly_name: Papier
which should be somewhere in your configuration.yaml (so not in the Lovelace card).
the lovelace auto-entities card will show these sensors, with their customized images, instead of the default mdi:icon.
This is exactly what I am looking for.
I think thought that is has to be in a separate file “customize.yaml”
Thx, works perfect
nope, it cán be, but doesn’t have to be.
It hás to be in the hierarchy I posted, and where you put that is up to you.
personally, I have all my generic customizations in a dedicated package, and all specific ones in their own package along with all other configs of that specific set of integration / uses.
is there any way to use auto-entities with button card?
Sure. You can use any (?) card within the auto-entities.
I use custom:button-card to display the pollen-forecast:
- type: 'custom:auto-entities'
card:
title: 'Pollen: Heute'
type: entities
style: [...]
filter:
include:
- entity_id: sensor.fc1*
state: low
options:
type: 'custom:button-card'
entity_id: this.entity_id
layout: icon_name_state2nd
styles: [...]
show_label: true
label: niedrig
show_state: false
I dont know if that is exactly what i need. i Want to generate and sort entities i specify in include option to generate button like this in horizontal-stack-card
hey all,
is there a way to do an “or” statement for the “state” which you have within include?
i wanted to include either “error” or “unavailable” here:
include:
- label: Robots
type: section
- name: '*Rover*'
domain: vacuum
options:
name: Rover Issue
type: 'custom:secondaryinfo-entity-row'
secondary_info: '<b style=''color:red''>[[ vacuum.rover.attributes.status ]]</b>'
state: unavailable
i tried this both with and without the " and the - but didnt work
state:
- "unavailable"
- "error"