Last active
December 3, 2025 09:15
-
-
Save EverythingSmartHome/13f14c328669f72eee717752069a0398 to your computer and use it in GitHub Desktop.
A collection of useful templates for Home Assistant dashboards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {{ states.binary_sensor | |
| | selectattr('attributes.device_class', 'in', ['door','window']) | |
| | selectattr('state', 'equalto', 'on') | |
| | list | count }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% set AREAS = ['kitchen','office','bedroom','living room'] %} | |
| {% set DOMAIN = 'light' %} | |
| {% set ns = namespace(ids=[]) %} | |
| {% for a in AREAS %} | |
| {% set ns.ids = ns.ids + area_entities(a) %} | |
| {% endfor %} | |
| {{ expand(ns.ids|unique) | |
| | selectattr('domain','equalto', DOMAIN) | |
| | selectattr('state','equalto','on') | |
| | list | count }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Security 🔏 | |
| {% if states.sensor.open_doors_and_windows.state | int > 0 %} | |
| You have {{states.sensor.open_doors_and_windows.state}} doors/windows open. | |
| {% else %} | |
| All windows and doors are closed. | |
| {% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Lights 💡 | |
| You have {{states.sensor.kitchen_light_count.state}} lights on currently. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% set area_id = 'kitchen' %} | |
| {% set ents = expand(area_entities(area_id)) %} | |
| {% set lights = ents | |
| | selectattr('domain', 'equalto', 'media_player') | |
| | selectattr('state', 'equalto', 'playing') %} | |
| {{ lights | list | count }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% set area_id = 'kitchen' %} | |
| {% set ents = expand(area_entities(area_id)) %} | |
| {% set switch = ents | |
| | selectattr('domain', 'equalto', 'switch') | |
| | selectattr('state', 'equalto', 'on') %} | |
| {{ switch | list | count }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% set time = now().hour %} | |
| {% if time >= 5 and time < 12 %} | |
| {% set greeting = 'Good morning' %} | |
| {% elif time >= 12 and time < 17 %} | |
| {% set greeting = 'Good afternoon' %} | |
| {% elif time >= 17 and time < 24 %} | |
| {% set greeting = 'Good evening' %} | |
| {% elif time >= 0 and time < 5 %} | |
| {% set greeting = 'You should be sleeping' %} | |
| {% endif %} | |
| # {{greeting}}, {{user}}! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% set time = now().hour %} | |
| {% if time >= 5 and time < 12 %} | |
| {% set greeting = 'Good morning' %} | |
| {% elif time >= 12 and time < 17 %} | |
| {% set greeting = 'Good afternoon' %} | |
| {% elif time >= 17 and time < 24 %} | |
| {% set greeting = 'Good evening' %} | |
| {% elif time >= 0 and time < 5 %} | |
| {% set greeting = 'You should be sleeping' %} | |
| {% endif %} | |
| {% if state_attr('calendar.lewis_s_calendar', 'start_time') == None %} | |
| {% set cal_message = "you have no upcoming events, enjoy 🥳"%} | |
| {% else %} | |
| {% set start_time = state_attr('calendar.lewis_s_calendar', 'start_time') | as_timestamp | timestamp_custom("%H:%M", false) %} | |
| {% set cal_message = "your next event is at " + start_time %} | |
| {% endif %} | |
| # {{greeting}}, {{user}}! | |
| It's {{now().hour}}:{{now().minute}} and {{cal_message}}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To add more areas, use this code and it works for me.
{% set AREAS = ['Kitchen', 'Office', 'Bedroom', 'Living Room'] %}
{% set DOMAIN = 'light' %}
{% set ns = namespace(ids=[]) %}
{# Recorre las áreas y busca entidades de varias formas para asegurar compatibilidad #}
{% for area in AREAS %}
{% set area_id = area | lower | replace(' ', '_') %}
{# Búsqueda normal por ID normalizada #}
{% set found = area_entities(area_id) %}
{# Fallback: usar atributos area_id de las entidades #}
{% if found | length == 0 %}
{% set fallback = states
| selectattr('attributes.area_id','equalto', area_id)
| map(attribute='entity_id')
| list %}
{% set found = found + fallback %}
{% endif %}
{# Último intento: usar el nombre tal cual (por si el area_id no está normalizado) #}
{% if found | length == 0 %}
{% set alt = area_entities(area) %}
{% set found = found + alt %}
{% endif %}
{# Acumular resultados #}
{% set ns.ids = ns.ids + found %}
{% endfor %}
{# Filtrar entidades del dominio (light, switch, etc.) y encendidas #}
{% set encendidas = expand(ns.ids | unique)
| selectattr('domain','equalto', DOMAIN)
| selectattr('state','equalto','on')
| list %}
{{ encendidas | count }}