Wash the potatoes and cook covered for about 20 minutes. Quench, peel, let cool and cut into slices. Clean, wash and slice the mushrooms. Wash the thyme and, except for something to garnish, pluck it off.
Peel and dice the onion, sauté in 2 tablespoons of oil, add the mushrooms. Fry on high heat for about 10 minutes until all the liquid has evaporated. Season with thyme, salt and pepper.
Whisk eggs and milk together, season with salt, pepper and possibly nutmeg. Rasp cheese.
Layer the potatoes, mushrooms, ham and 2/3 cheese in a large oiled casserole dish, pouring a little egg milk over each layer. Finish with the potatoes and sprinkle with the remaining cheese.
Bake in the preheated oven for 35-40 minutes at 150 degrees Celsius. Sprinkle with the remaining thyme.