List of devices with relevant entities and entity ids

I would like generate a list (json format preferred, but yaml is fine too) of devices in a given HomeAssistant instance, with the associated entities and those entities’ entity_ids.

Ideally, I’d do this using the REST API detailed here: REST API | Home Assistant Developer Docs

However, the closest request I’ve seen in the documentation is GET /api/states/, which would list state information for all entities, and those entities’ entity_id, but not which device each entity is associated with.

I’ve also looked at the alternative of the core.device_registry and core.entity_registry files in the .storage folder. However, I do not see anything in those files that indicates which device an entity is associated with.

I am running HomeAssistant Container, on version 2022.8.6.

I appreciate any help in figuring out how to gather this information. Thank you!

I believe there is a template function for that.

1 Like

@finity Thanks!

I’ve used templating within scripts and automations before. I’ll see if I can write a script using these template functions that will do what I need, and make the information available where I need it.

This may get tricky, though, since I need to be able to access the information from outside HomeAssistant (thus my hope to use the REST API or the files in .storage).

2 Likes