I am currently working on Home Automation Project with Raspberry Pi, I am using 8 channel relay board for this, I can control switches over relay easily. But I want to operate them with pre-existing buttons too in my home. So if I want to switch on/off any switch manually, I can do it. Can someone suggest me how to do wiring for that? So I can switch over relay and manual switches.
The double switch method (also called a staircase switch) would be preferable, as it's easier to integrate with existing wiring, but it leaves your Pi without knowledge about the state of the load.
As I see it you have two options:
Make the switch pull an input high or low on the Raspi, which you then use in your code to control the lamp or other load appropriately. This is by far the easiest to code for, but leaves you lamps at the mercy of the Raspi's reliability.
Utilize the double switch arrangement, and use a sensor to detect if the lamp is on. This means you have less wiring to do on the AC side, but you need to handle more possible cases in code. An LDR for example would work great for detecting if the lamp is on or off.
I think I found what you are looking for :
In this exemple, we see that two switches are controlling one lamp, so toggling one of these switch will toggle the lamp.
In your case, you need to consider your relay as the first switch, and your pre-existing switch as the second one.
Image taken from : https://diy.stackexchange.com/questions/31632/wiring-a-double-light-switch
If the previous solution isn't feasible because of the lack of wires in your walls, a workaround would be to use some wireless button pusher, instead of your relay.
So both humans and "computers" will physically be able to push your switches.
This method has a backdraw : it seems to need a specific OS to work on the rasberry, as discussed here.
If I understand your problem, you have to branch the relay and the manual switch in parallel, and both in serial with the bubble. This way either the manual pression or the electrical relay will be able to switch on/off. The question is do you want to do when both switch are in the ON position and a switch off is required? if both manual and relay must commute it is ok, but if you want a single action, you have to use a 'va et vient' switch. look at the animation and wiring here
After your comment on Technico.top's answer I think I understand what you want. Normally this would be done with a dual switch setup like the one below, where one of the switches would be your relay.
From what I understand you want to be able to switch the light to the desired status with your relay at any time. Someone switching the manual switch in this setup, would mess up your knowledge of the lights current status.
The only other setup I can think of is one I have in place myself, but it requires replacing your existing switch from a toggle switch to a momentary switch:
Your relay setup would be the same in the image in your post. The momentary switch would however also need to be connected to a GPIO and GND on the Raspberry Pi. You could use your current (normal) toggle switch as a momentary switch by briefly switching it on and off, but that requires user behavior.
Your program would require a variable to know the status of the relay so you can have multiple ways to toggle it.