def _white_levels_to_color_temperature(
    cold: int,
    warm: int,
    min_kelvin: int,
    max_kelvin: int,
) -> tuple[int, int]:
    """Convert whites to color temperature in kelvin.

    Returns a tuple (color_temperature, brightness).
    """
    max_mireds = color_temperature_kelvin_to_mired(min_kelvin)
    min_mireds = color_temperature_kelvin_to_mired(max_kelvin)
    brightness = warm / 255 + cold / 255
    if brightness == 0:
        # Return the warmest color if brightness is 0
        return (min_kelvin, 0)
    return round(
        color_temperature_mired_to_kelvin(
            ((cold / 255 / brightness) * (min_mireds - max_mireds)) + max_mireds,
        ),
    ), min(255, round(brightness * 255))
Convert whites to color temperature in kelvin.

    Returns a tuple (color_temperature, brightness).
    
webapp/homeassistant_util_color.py