How to search the entity_registry and output a list of used voice aliases

in Discord I was helped by Petro to find a way to to search the core.entity_registry for those aliases and present a list of all used in the system.
Goal: when creating new aliases, dont use old ones… or similar for that matter, to not confuse the assistant …

each entry in entity_registry has a list for aliases. Either [], or like this:

        "aliases": [

we ended up suggesting a command in a terminal using:

import json
filename = r"\\homeassistant\config\.storage\core.entity_registry"
out = []
with open(filename, 'r', encoding='utf-8') as fh:
    data = json.load(fh)
    for entities in data['data']['entities']:
        for alias in entities['aliases']:
            if alias not in out:
  1. This does not require python on the HA system

  2. all it requires is access to your HA config folder

  3. you’ll have to use python >= 3

for that to work

I have 3, 2 should be ok too as I share via Samba. And yet:

I cant make this run from any terminal though, so to make discussing this somewhat easier, I am opening this quest here.

a jinja template would be nice, but then we would probably need to paste the full entity_registry, so that wont work…

python_scripts doesnt allow imports, and we need some import to JSON.

maybe there’s another solution>

Id appreciate what you can throw at me