How to sense AC voltage

Greetings Friends.

I am new to home assistant and have successfully setup a network to turn on and off relays and bulbs. However, the problem started when a relay was connected to a switch on a parallel connection.

The state changes when I turn on or off the bulb from a physical switch. On checking the forum and across the internet, I realized that a voltage sensor should be added. Now the question is what type of voltage sensor do I need?

There are close to 20 switches and I want a cheaper, but stable solution. Does a 4N25 work or H11AA1? These are not tested, but the information is found on the internet. Any help or circuit would greatly help.

Kindly suggest.

Noone to respond to this question?