EDIT: Oops, I meant to say hot/neutral for (+)/(-). I'm not completely educated in this as you can tell. ^_^;;

I live in the U.S. I'm attempting to figure out if it's possible to hook up a Sonoff Wi-Fi switch to my house's light fixture, let alone if it's possible to do it with the existing wall switch. I know there's Wi-Fi switches you can buy that only require you replace the existing light switch, but they're super expensive, and the Sonoff is only $4. So I want to get this to work so I can use my phone to turn the light on or off no matter where I am in the world. I also want to still use the existing wall switch to control the light. But I'm not sure it's possible since Sonoff outputs two wires whereas a regular light switch just cuts off the (+) wire to control the light.

Here is the current wiring setup of one of my ceiling lights and its wall switch:

enter image description here

The AC's (-) connects directly to the light's (-). Then the AC's (+) goes down to the wall switch (a switch leg wire, I'm told it's called), then back up again to the ceiling and into the light's (+). This way the switch turns on or off the (+) to activate the light.

My plan, if it will work, is to mount the Sonoff box above the light's junction box in the attic. Power the Sonoff with the AC's (+)/(-) from the light box, then feed Sonoff's outputted (+)/(-) back to the light. Simultaneously, have the AC's (-) connected to the light like now, then still have it's (+) going to the wall switch and back to the light to turn the light on or off like now.

This is my wiring plan: enter image description here

Would this wiring setup work to control the light with both Sonoff and the wall switch? If my diagram is correct, do I need the extra neutral wire going into the light, or is the one going through Sonoff enough?

Thank you!

  • You can do it as drawn in your diagram, note however that EITHER or both switch or wifi switch on will result in the light bring on. The wifi switch doesn't have enough contacts to make it 3-way. So if you turn wall switch on you can't turn off via wifi, and if wifi turned it on you can't turn it off with the wall switch.
    – Tyson
    Commented Jun 28, 2016 at 23:29
  • 1
    What you want is possible -- however, it's about the same cost as a wallbox type of wifi light switch. As an aside, this is not the place to cheap out on things...a cheap countertop just looks cheap, while a cheap electrical gizmo might get melty or try to give you a ZZZAP. (Or get red tagged by the next city inspector who comes through for not having a UL listing, for that matter -- inspectors don't have the time to take every cheap gizmo back to the lab for detailed acceptance tests!) Commented Jun 28, 2016 at 23:43
  • Do you have any recommendations for switches that would be cheap? Thank you! Commented Jun 28, 2016 at 23:45
  • 1
    Furthermore -- most wallbox type wifi switches require the neutral at the wallbox, not an old-style no-neutral switch loop like the one you have. So, you're going to either have to plunk down a bit of cash to run a new cable for the switch loop + the cost of a wallbox type wifi switch, or plunk down a bit of cash to get the parts needed to implement this without running new wires. Commented Jun 28, 2016 at 23:50
  • I went with the solution described here youtube.com/watch?v=ab472a40-co&t=274s , in short, flash the device with Tasmota and hook up the switch to gpio14 and ground.
    – pangyuteng
    Commented May 13, 2018 at 22:55

3 Answers 3


First, everything about the Sonoff stinks like cheap Cheese, so good bet it is not UL listed. RoHS and CE is nothing, and UL/CSA listings are often forged by those offshore manufacturers.

Mains electrical is serious business, and the stuff is already very cheap - $20 for a proper smart switch for instance. The only reason that price seems high is you have found this thing that is cheaper in several ways, most bad. Who cares? There will always be a cheaper piece-o-junk out there. Your time is valuable too.

In NEC jurisdictions you cannot install things not approved by your local inspector, who does not run his own testing lab, but simply gets a list of approved appliances from UL or similar entity. NEC 110.

You cannot mount outside a junction box

An electrical device cannot be mounted outside a junction box as you plan, unless the labeling or instructions tell you to install it that way - the labeling and instructions are part of the UL listing, the listing is contingent on it being installed properly, and it is illegal to install it contrary to those instructions (NEC 110.3).

Parallel switches in your plan are semi-OK

The fact that the Sonoff has netural coming in is simply due to the fact that it is a powered device and needs neutral for its own power. Whether it is switching neutral, I cannot guess: It may be possible to bypass its neutral output and serve the neutral from the other side - that depends (again) on the UL approved labeling and instructions on the device.

If that's the case, then having both the smart switch and the plain switch feed the light should be fine. The key rule is that in any cable, currents must be equal - cancel each other out. That is to avoid eddy-current heating.

Low voltage remote switches are even better

If Deepesh Golani's method of accessing the internal switch works, and (again) is supported by UL approved labeling or instructions, that is an even better way since it does not involve significant currents. If that power is low voltage, you would escape the requirement to use Class 1 wiring techniques, and could run remote switches with thermostat wire for instance.


Yes it's possible. There is already an existing switch in sonoff module for manual switching. U can solder that switch with 2 wires and use a manual pulse switch( the one we use in door bells). See the picture.enter image description hereenter image description here


I don't quite get your diagram, this has been done by alot of people, the sonoff goes on the switch live out of the switch, so light switch stays on forevermore and you just use the sonoff to disrupt the flow of electric IE she goes on and off, but im UK and we have very different electronic setups so I could be wrong

Not the answer you're looking for? Browse other questions tagged or ask your own question.