3 way switch with sonoff

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…

Hot off the press!
This is my “software” solution for the 3-way switch.

2 Likes

Nicely done, good bit of lateral thinking.

I am so happy to see this. I will be trying this upcoming week and see how it goes. I am Kind of gland at least one of the switch works in a case of the HA is down. Thank you for making this awesome video

You’re welcome!

1 Like

Is there a way to disable programming mode on Sonoff dual R2 when ground and button 0 are connected while powering, on tasmota firmware? The issue I am halving is that I when am using those two as a rocker switch. So basically when power goes out and come back while physical switch is turned on it goes into programming mode.

I see a following note on tasmota page so I am assuming you can’t disable it.

“NOTE Make sure not to use a switch that keeps the connection between GND and BUTTON 0 active while power is re-applied as the device will start in programming mode.”

The only work around I found is that when ever it kick it programming mode I have to flip the physical switch and turn the breaker off and the on.

Would there be a reason in 3-way switch setup per DrZz would sometime turn on by itself? I am having that issues. I believe its happening because automation keep triggering due to second sonoff which is not connected to light triggering on by itself. Am I the only one who is having this issue?

I would check to see when the automation is being triggered. I shouldn’t trigger by itself.

My sonoff is setup to turn on when the power is removed and come back on. For example, if you shut off the breaker and turned it back on, the light would be on without the button being pressed or HA doing anything. Could this be whats happening to you?

Plenty of discussion on here and it’s also covered in the tasmota wiki, sounds like you’ve got interference on the lines from the switch to gpio. Just needs a capacitor bridging ground and gpio14 if that’s the one you’re using… assuming that’s your problem obviously.

You can set it up so that only one sonoff actually controls the light. The others only send status of GPIO14 to the MQTT broker. The “four way” functionality is done through automations.

I liked DrZzz solution. But i want a solution thats is independent of hass.io. There another guy DrZzz refered to on the live stream who has a solution(its on yt)…sorta cos he wants you to run a single wire from one switxh to another. Totally not practicle. My solution to be independent of hass.io and also work with hass.io is to get the sonoff basic switch with RF. Then order the 433mhz trasmitter wall switches (aliexpress)for the the 2nd and/3rd switch. They are cheap pack of 3 for @$5.

1 Like

Hi, i would like to do a 3way switch for my hall (using 2x sonoff T1), but I want to have some sort of backup, if for some reason my HA goes down i want to keep using the 3way switchs is there any way to accomplish this?
Can you point me to the right direction?
Thanks

If you are talking about T1(a) connected to the light and T1(b) not wired to the light but only talking to HA/mqtt for 3-way automation, my understanding is when wifi’s out or HA’s down, (a) will still function like a normal 1-way switch but (b) will be useless.

I remember seeing discussions on tasmosta github about setting up (b)'s mqtt to communicate with (a) directly, not sure that was figured out though.

I did a couple configs here. It does utilize MQTT still which may or may not be part of your HA config but it doesn’t use HA automations. I have also done some configs for people using the websend tasmota commands that uses direct HTTP instead of MQTT.

@digiblur I watched your video when you first posted it and was wondering if there is a way to send MQTT messages from one switch to another with out having to have a Broker or if you always need a broker? Not that I would use it this way but I have had where my Raspberry Pi with HA and the broker has had issues and nothing worked. I have multiple sonoff’s such as a similar 3-way to your video that work via an automation but could potentially if viable skip the automation and broker if that was possible. But im not sure if HA could be integrated at that point or not.

Of course you’d need a broker if you are using MQTT, the switches are setup as clients. I know there is a KNX protocol in Tasmota but I’ve never messed with it or compiled it in.

For simplicity I’d setup the rules to publish back and forth via each switch via HTTP. You’d need to have the switches setup in your DHCP server/router as static IPs so they don’t change.

Instead of using the publish command in the rule you would do something like

websend [192.168.1.116] POWER TOGGLE

if you have a password/user combo you’d do it like this:
websend [192.168.1.116,user:pass] POWER TOGGLE

rule1 on button1#state do websend [192.168.1.116] POWER TOGGLE endon

Of course the 192.168.1.116 is the destination switch you are trying to send the command to.

1 Like