Colour changing light through switches

Hi, I have a lot of lights in my house that change colour when turned off and then turned on again, I have mqtt switches which I made using nodemcu and relays attached to them, Can anyone please tell me how I could have the same colour appear each time I switch it on using home assistant. Btw there are 3 colours in the light.