First prep the Madras onions/ shallots by trimming of both ends with a sharp knife. Then remove the outermost layer of each onion. When all are done, rinse them and drain well. Keep aside.
Next soak the tamarind in about 2 cups of warm water, rubbing the tamarind to loosen the pulp. Keep aside.
Grind the coconut and the Sambar spice powder together with a little water to a smooth paste. Keep aside.
Heat the oil in a pot or wok and add the mustard seeds. When they crackle add the lentils and let them fry to a golden brown but do not let them darken. Add the asafetida powder, the curry leaves and the onions and sauté the onions over a medium flame until the start turning a light brown. Do not let them darken.
Squeeze out the tamarind after extracting the pulp with your fingers. Discard the solids and pour the brown liquid into the onions. Add the turmeric powder and the salt, stir well and bring to a boil. Turn down the heat and cover. Let this simmer until the onions are cooked, and a bit soft.
Now mix in the cooked and mashed lentils and let it start bubbling. Cook for about 5 minute. Then mix in a couple of tbsp of water to the coconut paste and add that to the pot. Stir well and bring to a boil. Add the jaggery, mix and let it simmer for about 2 to 3 minutes.
Serve hot with Idlis (steamed savoury rice and lentil cakes)or Dosas (savoury South Indian rice and lentil crepes), or with rice and vegetables on the side.