I have been searching for a means to make my 3-Way switches smart with local control and accurate feedback for the current state of the lights. Some brands claim to be able to do this but their price is high and usually require their proprietary hub. My smart home is a hobby and needs to pass the WAF (wife approval factor) for price and ease of use. See below for my solution:
Original 3-Way Electrical Hot flow:
| Electrical Source |----------| Switch 1 |==========| Switch 2 |----------| Lights |
Summary:
The problem with Smart switches in the Above configuration is when you turn off power at Switch 1, you kill power to Switch 2. So don’t! The key to this setup is that you ensure the power is always ON at the Switch 1 relay and power is only toggled from the relay in Switch 2. Set up automations to toggle POWER at Switch 2 relay from either the Switch 1 or Switch 2 physical toggle switches.
Hardware:
2x Sonoff Mini Switch
2x single pole toggle switch (to replace 3-way toggle)
Electrical:
Disclaimer – I am not an electrician. Please consult a professional. Always ensure Power is cut at the breaker before doing any electrical work. Use an electrical tester.
There are 2 Hot traveler wires that span from Switch 1 to Switch 2. This is what traditionally allows the 3-Way switches to work. In this setup, we want to always pass power through Switch 1 to Switch 2. I used the Black traveler wire for this and just capped the Red traveler wire at both ends. In my setup below, Connect the Black Hot traveller to the Slave Switch L Out and then use the other end as the L In for the Master Switch. Replace your 3-Way toggle switches with standard (and cheap) single pole switches and connect them to S1 and S2 on the Mini. When installed you should have L In, N, L Out, S1, and S2 connected on each of the Sonoff Mini’s.
Electrical Hot flow after change:
| Electrical Source |----------| Slave Switch |----------| Master Switch |----------| Lights |
Software Setup:
- Flash Sonoff Mini’s with Tasmota for local only control. Use DIY mode to get on your Wi-Fi network and then flash with the Sonoff DIY Tools application. This ensures local only control and eliminates dependence on the ewelink infrastructure.
- Set up MQTT communication with HA via Mosquitto Broker add-on
- Tasmota customizations:
- Console - ipaddress1 192.168.X.X (set static IP)
- Console - timezone -5 (set time zone for proper console reporting)
- Console - restart 1 (restart to set static IP)
- Configuration > Other
- Set Mini Template - {“NAME”:“Sonoff Mini”,“GPIO”:[17,0,255,0,9,0,0,0,21,56,0,0,255],“FLAG”:0,“BASE”:1}
- Check Activate
- Device Name and Friendly name
- same, title style description. Appears in header of Tasmota home
- Save
- Configuration > MQTT
- Set up MQTT info and structure
- Console - setoption19 1 (turn on MQTT discovery)
- Set up one Mini as a Slave where the Relay is always on and disable toggle switch control of relay
- Console - PowerOnState 1 ( powers ON relay at startup in case power loss)
- Console - Rule1 ON Switch1#State DO Event sendPower=1 ENDON ( When switch is toggled, keep power on, don’t toggle relay)
- Console - Rule1 1 ( activate Rule1)
Automation options:
Set up an automation to toggle the relay POWER on the Master Switch when the physical toggle switch is toggled at the Slave Switch.
-
Node Red – The automation is easy and only includes 3 Nodes
-
MQTT In Node – Set topic of the Slave Switch MQTT topic and add “ /SWITCH1T ” to the end
-
Change Node – Set msg. Payload to string “ toggle ”
-
MQTT Out Node - Set topic of the Master Switch MQTT topic and add “ /cmnd/POWER ” to the end
-
-
Home Assistant Automation (I use Node Red but I think this is all that’s needed)
-
Set the Trigger to be the MQTT topic of the Slave switch as noted above
-
Set the Action to Call Service, MQTT: Publish Service with the Master Switch topic as noted above
-
To display the state of the lights in your Lovelace page, just use the Master Switch as your HA Entity.