def METHOD_NAME(value):
    board: str = CORE.data[KEY_LIBRETINY][KEY_BOARD]
    board_pins = _lookup_board_pins(board)
    # check numeric pin values
    if isinstance(value, int):
        if value in board_pins.values() or not board_pins:
            # accept if pin number present in board pins
            # if board is not found, just accept all numeric values
            return value
        raise cv.Invalid(f"Pin number '{value}' is not usable for board {board}.")
    # check textual pin names
    if isinstance(value, str):
        if not board_pins:
            # can't remap without known pin name
            raise cv.Invalid(
                f"Board {board} wasn't found. "
                f"Use 'GPIO#' (numeric value) instead of '{value}'."
            )
        if value in board_pins:
            # pin name found, remap to numeric value
            if _is_name_deprecated(value):
                number = board_pins[value]
                # find all alternative pin names (except the deprecated)
                names = (
                    k
                    for k, v in board_pins.items()
                    if v == number and not _is_name_deprecated(k)
                )
                # sort by shortest
                # favor P# or PA# names
                names = sorted(
                    names,
                    key=lambda x: len(x) - 99 if x[0] == "P" else len(x),
                )
                _LOGGER.warning(
                    "Using D# and A# pin numbering is deprecated. "
                    "Please replace '%s' with one of: %s",
                    value,
                    ", ".join(names),
                )
            return board_pins[value]
        # pin name not found and not numeric
        raise cv.Invalid(f"Cannot resolve pin name '{value}' for board {board}.")
    # unknown type of the value
    raise cv.Invalid(f"Unrecognized pin value '{value}'.")