def fix_xiaomi_battery(value: int) -> int:
    """Convert battery voltage to battery percent."""
    if value <= 100:
        return value
    if value <= 2700:
        return 0
    if value >= 3200:
        return 100
    return int((value - 2700) / 5)