def get_supported_features(hass: HomeAssistant, entity_id: str) -> int:
    'Get supported features for an entity.\n\n    First try the statemachine, then entity registry.\n    '
    if (state := hass.states.get(entity_id)):
        return state.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
    entity_registry = er.async_get(hass)
    if (not (entry := entity_registry.async_get(entity_id))):
        raise HomeAssistantError(f'Unknown entity {entity_id}')
    return (entry.supported_features or 0)
Get supported features for an entity.

First try the statemachine, then entity registry.
def get_supported_features(hass: HomeAssistant, entity_id: str) -> int:
    'Get supported features for an entity.\n\n    First try the statemachine, then entity registry.\n    '
    if (state := hass.states.get(entity_id)):
        return state.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
    entity_registry = er.async_get(hass)
    if (not (entry := entity_registry.async_get(entity_id))):
        raise HomeAssistantError(f'Unknown entity {entity_id}')
    return (entry.supported_features or 0)