3 way switch with sonoff

Incorrect. He is referring to a 3-way switch configuration. a light (or set of lights) controlled by two switches is a 3-way switch configuration. His wiring is currently as he describes one switch per light which is a 2-way switch. What you mentioned (one light with three switches) is a 4-way switch configuration.

He’s on the right track with suggestions from people to use the Tasmota firmware on a sonoff. I’ve never done it but in theory it works wether you re-wire and use some wire as signaling, or run a secondary wire for control.

It’s you who’s incorrect, perhaps try using Google before replying next time…

http://www.lightwiring.co.uk/tag/2-way-lighting-circuit/

http://www.lightwiring.co.uk/tag/3-way-lighting-circuit/

I also have several Sonoffs running Tasmota using existing switches connected to the gpio.

And that is where UK Electrical Code and NEC (North American Electrical Code) differ. A 2-way configuration in the UK is the same as a 3-way configuration in North America electrically, but nomenclature is different. So really we are talking about the same thing. Also a 3-way configuration in the UK is the same as a 4-way configuration in North America electrically, again the nomenclature is different. And for the record, I didn’t need to use Google as my Dad is a Licensed Master Electrician in the US and I learned from him.

Because no one stated their location, people make assumptions. I made an assumption based on my location (North America, specifically the states) and you made an assumption based on your location (UK). Until the OP states their location, we are both wrong (or correct depending on your point of view).

Regardless, the Tasmota firmware for the Sonoff and a little MQTT magic (maybe an additional control wire) will solve their issue.

2 Likes

Should’ve guessed given you lot have a record of not being able to spell and using the wrong words to describe things :slight_smile:

Yup I am sorry. I did not say where I am which is the USA. I too was an electrician. My problem is with the coding. :slight_smile: I do know that I can wire a switch on to the sonoff board i just dont know fully enough rhe configuration both on them and in HA. Radebe2k mentioned what sounded like a way to habe the input switch be on a different topic than the relay. If thats the case i believe i can figure out the code as where i could not get my head wrapped around was that to my knowledge when you activated the switch on the sonoff it would activate the relay even if it isnt communicating with the broker. If i can use the switch on the sonoffs it would be easy to write an automation to control the relays.

Watch this…

and this…

…and then let us know where your unclear.

Setting up the individual light switches is easy, as is the automation, it’s just the end result that’s clever and you don’t need to do anything else for that :slight_smile:

I have flashed my current sonoffs (for other lights) with tasmota and watched the bottom video last night prior to this post. Since I do not have any to play with currently (as my current ones are in use) I think im having an issue on GPIO14 and understanding how it works. The way it looks in the video is it essentially works the same as the push button on the board except you can set it to work with a normal rocker switch which when the switch is “turned on” GPIO 14 would be pulled HIGH to switch the relay on and LOW when its turn off. Now the question is does it actually still control the relay directly or is it strictly just a sensor that can be utilized in HA?

The reason I ask this is with a 3 way switch (2 switches and 1 light or any amount of lights tied together) setup the rockers will not always be in a matching up down position. Such as if both rockers are currently in the down (Normally off) position then I turn Rocker 1 to the up position to turn the light on but then use Rocker 2 to turn the light off Both switches will now be in the on/up position. If understand how the sonoff configuration is working correctly the lights will just stay on.

Now you can tell me I am digging to deep into this and that you can make it work the correct way with HA automations but I guess i would need to see an automation to understand how it would work. If GPIO 14 is strictly capable to be used as a Sensor in HA with no direct control of the relay I can figure out the automation easily but if it does control it directly like i suspect thats where i need the help understanding.

I hope this makes sense and you can follow. I promise i’m not trying to be difficult. :slight_smile:

Thanks for all the help in advance.

You’re overthinking it, take it at face value and it really is simple.

If you set the GPIO14 sensor to 09 Switch1 in the web ui, the state of the switch is triggered when there is a change in the state between GND and GPIO14 on the board, it doesn’t matter whether it is low to high or high to low, if the switch is on it will go off, if it’s off it will go on, in your terms the way up the switch is is irrelevant. The Sonoff broadcasts it’s state to MQTT so HA reflects that in the front end. This is why you can use a traditional switch connected to GPIO14 and GND on the Sonoff to toggle it rather than kill the power to the whole thing. You do that to your other light as well so you have to independent switches operating the same.

The magic happens when you then set up the automation in HA as I have explained before, you use the trigger of the state of one light changing to toggle the other and vice versa, simple as they come.

Then you’ll have what appears to be a normal two way circuit, using three way switches if you want to use the daft US naming convention, which can be controlled by either of the physical switches or any number of remote ways via HA and everything will stay perfectly in sync.

I have a little vero board that contains a 2 way screw terminal, a 3 way header, a 10k resistor and a 1uF cap, the cap goes between ground and gpio14 and the resistor goes between 3.3v and gpio14. Hopefully it’s needless to say that DO NOT CONNECT THIS TO 240\110VAC this is for signalling only, not power supply.

basically what this little doohickey does is filter out any noise inducted onto the old switch wires as a lot of the wall switch cabling will run in bunches next to other live lines, this will increase the noise on the signal going to GPIO14 and cause the unit to switch when you don’t want it to, trust me i’ve had the unintentional disco lights happening outside the front of my house all night before.

2 Likes

Haven’t had any problems with any of mine but I can see it could be an issue with longer cable runs to the switch eg Sonoff at the light fitting rather than by the switch.

Thanks for posting, very simple solution :+1:

Thanks Bobby_Nobble that makes sense now.

Hey Guys, I just tried this with a couple that i have and it works great. Thanks for the help on this.

More than welcome, glad to hear you’re all sorted :+1:

As I’m sure you found, it’s far easier to do than talk about which is why I think a lot of people get put off by the guides.

Yes i would agree with that.

Hello,
I tried to get all the past reply together to get a conclusion but I’m new to this so I got a bit confused. I have I believe a 4-way switch ( 4 switches that control 5 lights in total on my hallway and stairs) I’m trying to figure out how to correctly wire the sonoff device followed by the correct setup on the software interface. Can someone help me out please. Thank you.

@Jaireco 4 way wiring is far more complex and can have many many different layouts inside the wall than any brief explanation in a forum could clarify. Using the Sonoff this way, I doubt that it would comply with any electrical codes so think about the consequences of a fire or ???

Can you tell me what you did

I followed the videos that Bobby_Nobble Posted above. Once I had the sonoff’s setup it was just a matter of setting up the automation. The Automation is a state trigger for each Sonoff switch. Remember this also is not strictly for sonoff’s as in you can mix a sonoff switch with a homseer switch. The Sonoff is just a cheaper way to make a current “dumb” switch into a smart switch.

I hope this makes sense. :slight_smile:

For instance:
You have 2 switches: Sonoff1 and Sonoff2. (My particular setup is not a current 3 way it is 2 2 ways (1 Switch, 1 Load) that I want to work like a 3 way.

- alias: Kitchen 3 Way On - Trigger Sonoff1
  trigger:
   - platform: state
     entity_id: switch.sonoff1
      to: 'on'
 action:
    service: switch.turn_on
    data:
      entity_id: switch.sonoff2

- alias: Kitchen 3 Way Off - Trigger Sonoff1
  trigger:
    - platform: state
      entity_id: switch.sonoff1
      to: 'off'
  action:
    service: switch.turn_off
    data:
      entity_id: switch.sonoff2

- alias: Kitchen 3 Way On - Trigger Sonoff2
  trigger:
    - platform: state
      entity_id: switch.sonoff2
      to: 'on'
  action:
    service: switch.turn_on
    data:
      entity_id: switch.sonoff1

- alias: Kitchen 3 Way Off - Trigger sonoff2
  trigger:
    - platform: state
      entity_id: switch.sonoff2
      to: 'off'
  action:
    service: switch.turn_off
    data:
      entity_id: switch.sonoff1

@Bobby_Nobble Is there a way that I can have 2 switches connected to one Sonoff basic and have each one trigger different events? It looks like you can utilize more than GPIO 14 but im not sure if I need to setup up something different to get it to send a seperate Topic for each or if it is already setup to which case how would the topics look?

Thanks @Radebe2k
I need this! I’m getting too many ghost switchings.
I told my kids it’s the ghost of Thomas Edison doing it. They didn’t get it…