Put the lentils and water in a saucepan with the sprig of thyme. Cook for 20 minutes from boiling.
Meanwhile, peel the tomato, peel the shallot. Cut the tomato and shallot into pieces. Put them in a small saucepan with a drizzle of oil (olive or sunflower) and the ham (optional). Cook over low heat for 5-10 min
When the lentils are cooked, discard some of the cooking water and add the tomato sauce. Mix for a long time. Add water if the soup is too thick or difficult to blend.