def _resolve_state(hass: HomeAssistant, entity_id_or_state: Any) -> ((State | TemplateState) | None):
    'Return state or entity_id if given.'
    if isinstance(entity_id_or_state, State):
        return entity_id_or_state
    if isinstance(entity_id_or_state, str):
        return _get_state(hass, entity_id_or_state)
    return None
Return state or entity_id if given.
def _resolve_state(hass: HomeAssistant, entity_id_or_state: Any) -> ((State | TemplateState) | None):
    
    if isinstance(entity_id_or_state, State):
        return entity_id_or_state
    if isinstance(entity_id_or_state, str):
        return _get_state(hass, entity_id_or_state)
    return None