Skip to content

Accessing entities within other integrations could be improved #20

@Big-Tree

Description

@Big-Tree

Checklist

  • I have filled out the template to the best of my ability.
  • This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
  • This issue is not a duplicate feature request of previous feature requests.

Is your feature request related to a problem? Please describe.

The method by which entities are are accessed and controlled is not officially supported. They may be better alternative methods:

def get_entity(hass: HomeAssistant, entity_id: str):
"""Get the entity associated with entity_id. It could be owned by another integration.
Accessing entities of other integrations does not seem to be supported. The method we use
seems a bit dodgy.
"""
entity_reg: RegistryEntry = entity_registry.async_get(hass).async_get(entity_id)
domain: str = entity_reg.platform
entity_coordinator: DataUpdateCoordinator = hass.data[domain][entity_reg.config_entry_id]
# Get the entity via the entity coordinator
for update_callback, _ in entity_coordinator._listeners.values():
if update_callback.__self__.unique_id == entity_reg.unique_id:
return update_callback.__self__

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions