Best way to control one light with several wifi wall switches

I was wondering what is the correct way to control one light from several switches?

My switches are wifi connected, I created 2 automation, one says if SW1 is ON OR SW2 is ON, LIGHT X will power ON, and the second automation does the contrary.

This works 9/10. The problem is that sometimes due to lantency of the network one switch can lag behind and when his state changes due to the automation, the whole thing goes into an infinite loop. Am I doing a hacky solution? is there a better way to do this? THANKS!

Forget the state of switches.
Stick to the state of the light only.

Hmm, reading your post again makes me think I might have been wrong.
I was assuming the setup would be a corresponding set of switches, so you could turn off and on on several switches.

But you description of your script indicates that you want a switch to disable the function of another, so if one is on, then the setting of the other is irrelevant.