I am trying to get a list of specific entities and it would be helpful to output the related integration associated with it. I can’t find any documentation on if this info is surfaced to the templating engine or not. Anyone have any ideas?
If you just want to know what integrations are associated with which entities that info is already listed in the entities section of the configuration menu.
If you need it to output that info to a sensor to display in lovelace then I’m not sure how you would do that.
If you’re trying to do this with a template, as far as I know, it’s not possible. An entity’s integration would need to be one of its attributes so that the template could access it (using the state_attr() function).
It’s for this very reason that I have manually added a custom attribute, called integration, to each entity. For more information, refer to this post:
For context, this is so I can get a list of unavailable entities, which I have, but I thought it would be nice to see the integration next to the entity because some are actually “offline” while others are because I’ve moved them from Smart Life to ESPHome. When doing large refactorings of my setup, it would be helpful to focus on those of a specific integration. While wishing, would be nice to be able to get the device ID and name assosciated with an entity too.
So, I really need to get the info that is in Home Assistant - this is not long term retention or anything like that where adding it as a custom attribute would be worth the time involved.
I now use a Macro that employs a more up-to-date method that was provided by template master petro
Notice: A device may “belong” (be associated with) to more than one integration - this macro returns the name of the first found integration in the list of linked integrations
{# --------------------------------------------------- #}
{# Find the integration of a device or entity #}
{# --------------------------------------------------- #}
{%- macro get_integration(device_or_entity_id) -%}
{{-
[device_or_entity_id]
| map('device_attr', 'identifiers')
| reject('none')
| map('list')
| reject('eq', [])
| map('first')
| map('first')
| first
-}}
{%- endmacro -%}