def get_capability(hass: HomeAssistant, entity_id: str, capability: str) -> (Any | None):
    'Get a capability attribute of an entity.\n\n    First try the statemachine, then entity registry.\n    '
    if (state := hass.states.get(entity_id)):
        return state.attributes.get(capability)
    entity_registry = er.async_get(hass)
    if (not (entry := entity_registry.async_get(entity_id))):
        raise HomeAssistantError(f'Unknown entity {entity_id}')
    return (entry.capabilities.get(capability) if entry.capabilities else None)
Get a capability attribute of an entity.

First try the statemachine, then entity registry.
def get_capability(hass: HomeAssistant, entity_id: str, capability: str) -> (Any | None):
    'Get a capability attribute of an entity.\n\n    First try the statemachine, then entity registry.\n    '
    if (state := hass.states.get(entity_id)):
        return state.attributes.get(capability)
    entity_registry = er.async_get(hass)
    if (not (entry := entity_registry.async_get(entity_id))):
        raise HomeAssistantError(f'Unknown entity {entity_id}')
    return (entry.capabilities.get(capability) if entry.capabilities else None)