Putting a Sonoff in your wall switch box

Tags: #<Tag:0x00007f7397651730> #<Tag:0x00007f73976515c8> #<Tag:0x00007f73976510c8>

I’ve been installing Sonoffs with Tasmota in my light switch boxes. Works great! Full control of the lights for automations, but still have the normal look and feel of the standard switch.

Not everyone is comfortable opening a wall switch box and monkeying with the wires.
It’s not too hard and it CAN be done safely. Make sure you turn off the breaker, unless you enjoy sparks and shocks.

Not sure an electrical inspector would be too keen on the way I “insulated” the Sonoff boards.


Nice video, I did almost the exact same thing a couple of days ago although I flashed my firmware over the wifi and I had to hook up to a three light switch controlling one light setup.

Today, I’m going to change a motion sensor flood light I have outside into a controllable light and a motion sensor for HA. I’ll hook up the motion sensor relay to the gpio pins like you did for the switch.

excellent! Thanks!
I have a couple of non-working outside motion lights too. I need a good solution.
I may have to try that OtA flashing process.

Have done all my outside lights to use the original switches, only ones that have neutral wires to the switch in the UK, now going to knock up a couple of ‘Sonoff sockets’ from dead RF ones for seasonal use like the Christmas tree.

Loving these things :slight_smile:

I’ve got the Dual and 4 pole Sonoffs in the mail. Should be here soon. Excited to try them out.

I hope you make a video on the dual Sonoffs. I have lots of switches in sets of two.

Do you know of any tutorials that have instructions how to use 1 Sonoff with a light that has multiple switches (3 way switch) and have all switches be able to controls the light?

It wouldn’t be any different to this, just install the Sonoff at the switch that feeds the power to the light and leave everything else alone.

I would like to see this also! -Thanks

Nice video. I’ve watched it a couple of times, and am confused about the rocker switch/Sonoff functionality.

You’re not making the physical rocker switch and the sonoff each have toggling functionality, are you? In other words, it’s an and situation and not an xor, right? You need both the rocker-switch to be in the on position, as well as the Sonoff to be on in order for the light to power.

It’d be sweet to have a circuit so that the rocker switch could control the light status in combination with the Sonoff.


  • Light Switch is in On Position, but Light is off (presumable powered off by the Sonoff)
    • Rocker switch down will do nothing, but
    • Rocker up again will turn on the light
  • Light Switch is in Off position, but Light is off
    • As expected, flipping Rocker up will turn on the light.


I did a four switch which was wired with a pair comming from the top and pair comming from the bottom like this.

Are you wired like this?

I’ll put 3-way switch on my video “to-do” list.

No. the rocker and the sonoff button or the mqtt command all just toggle the lights. That’s the beauty of TASMOTA. It makes it so any input (rocker, sonoff board push button, or mqtt command) will toggle the lights. So if the lights are off, any one of those actions will turn them on. And the same goes when the lights are on.

I’ve got my Sonoff Dual sitting on my desk. For this week’s video I’m doing more about Holiday LEDs (since that’s a popular topic right now), but the week after I’ll either do the Sonoff Dual, or a Three-way switch with a sonoff or Sonoff flashing Over-the-Air. Which ever project I can get working first I’ll do next.
I think those will be the topics for the next 3 weeks. Just working on which order they’ll be done in.

Thanks for the support fellas!


Another feature of the sonoff with 3+ light switches is that when one of the other light switches is used, it turns the power off on the sonoff and when its turned back on, the sonoff starts on. This allows the other switches to control the light by turning them off and then back on.

RobDYI, can you explain this a little more? I think I follow but not 100%. I have a couple of lights that are currently not 3 way switches but I was hoping i would be able to turn them in to 3 way switches by using a Sonoff and code in HA.

Its a hall that has 2 lights at each end but they didnt not wire them together for a 3 way so one switch controls the light closest to it and same goes for the other. I would like to have them both turn on and be able to control it like a 3 way and not have to run the another wire.

As I postedl on the other thread you started you are after a creating a two way circuit not three but RobDYI is describing adding a Sonoff to an existing properly wired multi way circuit.

To avoid wiring it properly, you could use a Sonoff on each circuit and then set up automations in HA where one Sonoff being turned on would trigger the other and vice versa.

I think Bobby is right, it appears you have one light and one switch at one end of the hall and a totally separate light and switch at the other end. If the two light - switch combos are not connected, you will need two sonoffs to control both lights.

If the lights are connected, then it might be possible to get it to work with one sonoff.


Correct. Two completely separate switches which would take 2 sonoffs. I guess where my issue is how to get the sonoff to work correctly or HA to make it work.

I actually started another thread specifc to my situation here. 3 way switch with sonoff

Which specific bits are you unsure of?

There are many guides to flashing Tasmota onto a Sonoff and then setting it up to use the wall switch as a toggle, along the necessary MQTT set up in HA to use it. Then it’s a bog standard automation to get them to work together.

This maybe a stupid question but im just getting into playing with the Sonoff’s and I really like your setup of putting them in the wall.
Once all said and done, are they still controllable via google home voice command. I currently have 1 sonoff switch on one of my pendant lamps and 1 sonoff touch controlling my kitchen lights both controllable by voice command using my google home mini.