Hi. Is there a way to count how many entities there are in the result? For example if I set up som filter to warn me about low batteries etc it would be nice if I was able to print “You have xx warnings”
Surely in some cases template-entity-row is the simplest solution, it depends.
Not to mention a fact that “last-changed” label is NOT periodically updated for template-entity-row (only when a state changes or a page refreshed) as it is for a conventional entity row (periodically).
tbh I always use the last-changed on states in the config.entity, so they are always correctly updated. you might be right for other situations, I confess I bever watched that. Should be an important aspect in choosing the right card.
See this rather complex composite of card_mod_theme, card_mod and template-entity-row. whish I could be simpler…
luckily, we can just completely throw it inside an anchor and repeat for the another entity::
type: entities
title: Luchtreinigers
card_mod:
class: class-header-margin
entities:
- type: custom:template-entity-row
# https://community.home-assistant.io/t/card-mod-add-css-styles-to-any-lovelace-card/120744/2182
entity: fan.luchtreiniger_hall
<<: &fan
# color: >
# {{iif(states[config.entity].state == 'on','red','black')}}
name: >
{% if states[config.entity] is not none %}
{{state_attr(config.entity,'friendly_name').split(' ')[1]}}:
{% set id = states[config.entity].object_id %}
Air quality:
{% if states('sensor.' ~ id ~ '_air_quality') in ['unknown','unavailable'] %}
{% if states[config.entity].state == 'on' %} Initializing
{% else %} Off {# Device not ready #}
{% endif %}
{% else %} {{states('sensor.' ~ id ~ '_air_quality')}} µg/m³
{% endif %}
{% else %} Not yet set
{% endif %}
secondary: >
{% if states[config.entity] is not none %}
{% set id = states[config.entity].object_id %}
{% if states[config.entity].state == 'on' %}
On: {{states[config.entity].attributes.percentage}} -
{% else %} Off since {{relative_time(states[config.entity].last_changed)}} -
{% endif %}
{% else %} Not yet set -
{% endif %}
Power: {{states('sensor.' + id + '_device_power')}} W
card_mod:
style:
div#wrapper: |
state-badge {
{% if is_state(config.entity,'on') %}
animation: rotation 2s linear infinite, colorize 5s linear forwards 1;
{% endif %}
}
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes colorize {
0% {
background: steelblue;
}
100% {
background: aquamarine;
}
}
# state: >
# {{iif(is_state(config.entity,'on'),'Aan','Uit')}}
icon: >
{{is_state(config.entity,'on')|iif('mdi:fan','mdi:fan-off')}}
# icon: >
# {{'mdi:record-circle-outline' if is_state(config.entity,'on') else 'mdi:fan-off'}}
toggle: true
- type: custom:template-entity-row
entity: fan.luchtreiniger_woonkamer
<<: *fan
Thanks, I thought it was possible with som sort of template. I just didn’t know i could use the filter when i created the template. I will have to look into that since i’m quite new to the coding part of HA (where you can do all the cool stuff)
Anyone know how to filter out entities/devices not assigned to an area? I know how to filter by devices assigned to an area but am looking for the opposite. Overall, I am trying to only show a list of switches assigned to an area ie if a switch has not been assigned an area it won’t show in the auto entities list.
I know a work around could be to include switch domain and include every area but this just feels like a lot of work when there should be exclude: null