Background
I am building a simple web application using raspberry as a server. I am using this raspberry also to control an arduino. A user can send commands through the browser to the raspberry, and it can control some arduino functions!
What I want
I want to use an arduino to turn a lamp on and off, parallel to a normal manual switch that I can use to turn on the lamp on and off, like this:
1: If the lamp is off and the switch is also on OFF position (open switch), I can turn the lamp on by using the switch, putting it on the ON position (closing the switch). Then, the monitoring system is gonna tell arduino (and the web server) that the switch is on/closed and the light is on.
2: I can use arduino to turn off the light, without necessarily puting the switch on the OFF position. If the light is OFF (because I turned it off using an arduino) and the switch is on the ON position (closed), I should need to switch it to OFF position and then to ON position again, in a manner that I can sense these changes and send it to arduino (and consequently, to the web server).
3 (Possible improvement?): Whenever I change the state of the switch, the light would change its state to whichever is the opposite of the current one: if the light is on, it goes off and vice-versa, regardless of the switch state.
The problem
How can I actually know if the switch is on and off? There is anyway to use a sensor, some electronic circuit or component that can if tell the switch is on or off? I was thinking about using a relay to control the light, depending of the state of the light that is stored on arduino/web-server. Is this a reliable way (I mean, using a relay) to do that?
I appreciate any possible help on this, I have been interested on IOT and I want to do some simple applications for home automation; this is my first one! Thanks in advance for any help, again.