Peel and finely dice the onions and garlic. Clean, wash and roughly grate the zucchini. Wash thyme, shake dry and remove leaves. Heat 1 tablespoon of oil. Fry half onions and half garlic in it until transparent. Add zucchini and half of thyme and steam for 3-4 minutes. Season with salt and pepper. Drain and let cool off.
Meanwhile boil 2-3 l salted water (1 teaspoon salt per litre). Heat 1 tablespoon of oil. Fry the rest of the onions and garlic until transparent. Add tomatoes and juice. Mash the tomatoes well with a spatula. Bring to the boil and simmer for about 15 minutes. Season to taste with salt, pepper and sugar.
Cook the pasta in boiling salted water according to the instructions on the packet, then drain and rinse. Mix ricotta, egg and zucchini. Season to taste with salt, pepper and nutmeg.
Preheat oven (electric cooker: 200 °C/circulating air: 180 °C/gas: see manufacturer). Pat the pasta dry and fill with the zucchini mix. Pour tomato sauce into an ovenproof dish. Put the noodles in it. Sprinkle with pine nuts and bake in a hot oven for about 25 minutes. Sprinkle with the remaining thyme.