Wash the potatoes and boil in water for about 20 minutes. Then rinse with cold water, peel and leave to rest for a while. In the meantime, clean the mushrooms and cut them into thin slices. Peel and finely chop the onion.
Wash and chop the thyme. Heat the oil. Sauté onion. Add mushrooms and fry over high heat for about 10 minutes. Season with salt and pepper. Whisk eggs and milk. Season with salt and pepper.
Grate cheese, cut potatoes into slices. Place prepared ingredients and cooked ham alternately in thin layers in a greased casserole dish (26 x 15 cm). Sprinkle each layer with egg milk.
Bake in the preheated oven (electric cooker: 175 °C/ convection oven: 150 °C/ gas: level 2) for approx. 45 minutes. Serve garnished with thyme.