def _from_percentage(percentage: int) -> int:
    """Convert percent to a value that the Tradfri API understands."""
    if percentage < 20:
        # The device cannot be set to speed 5 (10%), so we should turn off the device
        # for any value below 20
        return 0

    nearest_10: int = round(percentage / 10) * 10  # Round to nearest multiple of 10
    return round(nearest_10 / 100 * 50)