For as long as I've been playing with home automation, I've wanted a straight forward low-cost solution for replacing standard light switches. Although I have several Z-wave dimmers and Aeon Labs touch panels, these work out to be $180 NZD each! At least in NZ, the common 2-way and 3-way light circuits have the mains coming in on one switch and the load connected to another. The two switches are connected together as shown below.
While the excellent Fibaro dimmers allow for 2-way circuits, @ $139 NZD ea., that's not a cost effective long-term solution either. If you see this blog post, the author of Espurna firmware for Sonoff has written a post on how he achieved it using devices with two SPDT relays like the Electrodragon.
My solution is even simpler (?) and leverage's the rules capability built into ESPEasy along with another very cool feature. There are several ways to do this and the first is using UDP as the ESPEasy devices can know about and talk to each other without the need for a home automation controller!
To enable this, you need to define three things;
In my early testing, both units come on and off at the same time which is great. Controlling either unit with MQTT turns on the other at the same time. To my mind, this is even better than a standard 2-way circuit as both status LED's for the chosen light switch/LED combo are on when the light is on.
As the Sonoff's have a spare GPIO on pin 14, I'll bring this out externally to control a LED built-in to the stainless steel push button I'll be using or maybe I'll just leave the LED around the button on all the time (dimly).
## Sonoff1 ##
on button#state do
if [relay#state] = 0
GPIO,12,1
else
GPIO,12,0
endif
endon
on relay#state do
if [relay#state] = 1
gpio,13,0
Publish /sonoff2/gpio/12,1
else
gpio,13,1
Publish /sonoff2/gpio/12,0
endif
endon
## Sonoff2 ##
on button#state do
if [relay#state] = 0
GPIO,12,1
else
GPIO,12,0
endif
endon
on relay#state do
if [relay#state] = 1
gpio,13,0
Publish /sonoff1/gpio/12,1
else
gpio,13,1
Publish /sonoff1/gpio/12,0
endif
endon
My video on this working using MQTT below:
Great video on how to use ESPEasy rules here:
While the excellent Fibaro dimmers allow for 2-way circuits, @ $139 NZD ea., that's not a cost effective long-term solution either. If you see this blog post, the author of Espurna firmware for Sonoff has written a post on how he achieved it using devices with two SPDT relays like the Electrodragon.
My solution is even simpler (?) and leverage's the rules capability built into ESPEasy along with another very cool feature. There are several ways to do this and the first is using UDP as the ESPEasy devices can know about and talk to each other without the need for a home automation controller!
To enable this, you need to define three things;
- Turn on rules in the advanced menu.
- Enable UDP and define a port (I used 65432).
- Ensure your device has a unit number between 1-32.
In my early testing, both units come on and off at the same time which is great. Controlling either unit with MQTT turns on the other at the same time. To my mind, this is even better than a standard 2-way circuit as both status LED's for the chosen light switch/LED combo are on when the light is on.
As the Sonoff's have a spare GPIO on pin 14, I'll bring this out externally to control a LED built-in to the stainless steel push button I'll be using or maybe I'll just leave the LED around the button on all the time (dimly).
## Sonoff1 ##
on button#state do
if [relay#state] = 0
GPIO,12,1
else
GPIO,12,0
endif
endon
on relay#state do
if [relay#state] = 1
gpio,13,0
Publish /sonoff2/gpio/12,1
else
gpio,13,1
Publish /sonoff2/gpio/12,0
endif
endon
## Sonoff2 ##
on button#state do
if [relay#state] = 0
GPIO,12,1
else
GPIO,12,0
endif
endon
on relay#state do
if [relay#state] = 1
gpio,13,0
Publish /sonoff1/gpio/12,1
else
gpio,13,1
Publish /sonoff1/gpio/12,0
endif
endon
My video on this working using MQTT below:
Great video on how to use ESPEasy rules here:
Comments
Post a Comment