Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Home Assistant - How to generate a list of all entity IDs, grouped by area and device
(@hans)
Famed Member Admin
Joined: 13 years ago
Posts: 3147
Topic starter
August 7, 2026 2:29 AM
[#1576]
I needed a list of all entity IDs of home assistant, grouped by area and device, and sorted by domain to get something like this (just a part of the output):
Area: Master Bedroom
- Device: Google Mini Bedroom
* media_player.bedroom_speaker
- Device: Hue Light Bedroom Left
* light.hue_light_bedroom_left
* number.hue_light_bedroom_left_effect_speed
* select.hue_light_bedroom_left_power_on_behavior
* text.hue_light_bedroom_left_effect_color
* update.hue_light_bedroom_left
- Device: Hue Light Bedroom Right
* light.hue_light_bedroom_right
* number.hue_light_bedroom_right_effect_speed
* select.hue_light_bedroom_right_power_on_behavior
* text.hue_light_bedroom_right_effect_color
* update.hue_light_bedroom_right
...
The easiest way is by using Jinja2 code in a template:
Go to "Settings" -> "Tools" (used to be "Developer") -> templates and paste this code in the editor:
{# Get devices by area #}
{%- set assigned_entities = namespace(ids=[]) %}
{%- for area in areas() | sort -%}
{%- set area_name_val = area_name(area) %}
Area: {{ area_name_val }}
{%- for dev_id in area_devices(area) | sort(attribute='name') %}
{%- set dev_name = device_name(dev_id) %}
- Device: {{ dev_name }}
{%- set entities = device_entities(dev_id) | sort %}
{%- for ent in entities | sort(attribute='domain') %}
* {{ ent }}
{%- set assigned_entities.ids = assigned_entities.ids + [ent] %}
{%- endfor %}
{%- endfor %}
{%- endfor -%}
{# Get devices/entities not assigned to an area #}
Area: Unassigned / Floating Entities
{%- set all_entities = states | map(attribute='entity_id') | list %}
{%- set unassigned = all_entities | reject('in', assigned_entities.ids) | sort %}
{%- for ent in unassigned | sort(attribute='domain') %}
* {{ ent }}
{%- endfor %}
This produces a very clean list of all your entities.