Export entities to a file

i found a nice way to export the entity id’s and names to a file
i have 2 homeassitants , and use remote assistant ( via hacs)
but when i gather entities from the remote node i always had to look and find the entityid instead of the entity name .

i exported a list as follows

  1. Go to Developer ToolsStates (left sidebar)
  2. Right-click anywhere on the States page
  3. Select “Inspect” OR “Inspect Element” (F12 also works)
  4. Click “Console” tab at the top of the Inspector panel
  5. Paste the JavaScript code in the Console area
  6. Press Enterha_entities.csv downloads instantly!
// NAME = ENTITY_ID format + A-Z sort by NAME
let lines = [];
Object.values(document.querySelector('home-assistant').hass.entities)
  .forEach(e=>{
    if(e.name) lines.push(`${e.name.padEnd(30)} = ${e.entity_id}`);
  });
lines.sort((a,b)=>a.toLowerCase().localeCompare(b.toLowerCase()))
  .forEach(line=>console.log(line));

const txt = lines.join('\n');
const blob = new Blob([txt], {type: 'text/plain'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url; a.download = 'ha_entities.txt'; a.click();
console.log('✅ ha_entities.txt downloaded!');
1 Like