i am a green in the part of hardware. i don't know how
Don't start with mains - start with something that won't kill you. Hamilton started with go-karts before trying F1
For the theory bit (and it will work with low voltage, low current stuff, like LEDs) ...
A light-switch is just a moving bit of metal - when it's off, there's an air-gap; switch it on, the gap closes.
A relay does the same, except there's two air-gaps. The moving metal closes one gap and opens the other.
There's another sort of light-switch, a two-way one, which works like the relay - and quite often what's been installed is one of those, with the second part left unconnected. You may be lucky!
With an ordinary one-way switch, you could add a relay, but where you connect it depends on what you want to do.
If you put the relay in series, then you can switch the light off when it's on but not on when it's off - logical AND
If you put the relay in parallel, then you can switch the light on when it's off but not off when it's on - logical OR
If you want to do both - XOR - you need a two-way switch.
Now you need your Pi to detect whether the light is on or off. That's a whole new ball-game! Voltage sensing? what if the lamp is bust? Current-sensing? Light sensing?
Draw it out on paper, then try it with the Pi and LEDs then get your friendly neighbourhood electrician involved ...
Love that machine, DirkS!
