Page 1 of 1
ESP8266 MQTT switch with local on/off and feedback
Posted: Monday 11 June 2018 19:53
by SweetPants
Project Scope:
When entering my house I want to be able to switch the light in the halway automatically between sunset and sunrise. So when the door opens, switch On the light for say 1-2 minutes and switch Off again using dzVentz. But I also want to be able to switch on/off the light using the existing wall switch(es).
This could be done using an extra (ESP8266 driven) relay in parallel with the original wall switch, but then you are not able to switch off the lights anymore with the wall switch and this is not suitable when having a hotel circuit (2 or more switches in series)
This could be solved by buying (expensive) wall switches which most of the time do not fit into the wall box or are totally different from the original.
Solution:
I've created an ESP8266 enabled switch that can be switched using MQTT, but also takes the switch wire from the wall switch as an input and do local switching if needed. When the wall switch is toggled, the switch also sends an MQTT update to domoticz to update the current switch state. The module is located in or near the lamp, so in case of a hotel circuit, it also works.
First test looks promising
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Tuesday 12 June 2018 23:05
by kimot
ESPeasy works the same way without need scripts in Domoticz and works if Domoticz is down too.
Domoticz only sends "events" sunset, sunrise, switch slamp ( for remote control ) etc. Other ESPeasy sends door contact state to first (lamp) ESPeasy
This ESPeasy monitors mechanical switch state too, reports lamp state back to Domoticz and control lamp relay ( with timers if needed )
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Wednesday 13 June 2018 14:50
by SweetPants
kimot wrote: ↑Tuesday 12 June 2018 23:05
ESPeasy works the same way without need scripts in Domoticz and works if Domoticz is down too.
My solution does that too, no need for scripts, and no need to modify wall switches, just sense the presence of a switch signal, but you need some additional hardware to do that. And how about hotel circuits with two or more wall switches?
Edit: Have a second one running now on a 3 switch hotel circuit. Still looking good
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Friday 17 August 2018 13:41
by ronschaeffer
Sounds really interesting. Please post some details about your hardware set up to detect the wall switch toggle. Thanks!
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Friday 17 August 2018 14:30
by SweetPants
ronschaeffer wrote: ↑Friday 17 August 2018 13:41
Sounds really interesting. Please post some details about your hardware set up to detect the wall switch toggle. Thanks!
Schematic: (The circled part converts the wall switch signal to something the ESP can handle
Feedback_Switch.png
Hardware:
Hardware.jpg
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Monday 20 August 2018 16:43
by ronschaeffer
Thanks. Have you been happy with the performance?
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Monday 20 August 2018 18:43
by SweetPants
ronschaeffer wrote: ↑Monday 20 August 2018 16:43
Thanks. Have you been happy with the performance?
What performance? It's just a switch and it takes only a few msec to switch either locally or via MQTT
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Monday 20 August 2018 23:21
by Derik
SweetPants wrote: ↑Monday 11 June 2018 19:53
Project Scope:
When entering my house I want to be able to switch the light in the halway automatically between sunset and sunrise. So when the door opens, switch On the light for say 1-2 minutes and switch Off again using dzVentz. But I also want to be able to switch on/off the light using the existing wall switch(es).
This could be done using an extra (ESP8266 driven) relay in parallel with the original wall switch, but then you are not able to switch off the lights anymore with the wall switch and this is not suitable when having a hotel circuit (2 or more switches in series)
This could be solved by buying (expensive) wall switches which most of the time do not fit into the wall box or are totally different from the original.
Solution:
I've created an ESP8266 enabled switch that can be switched using MQTT, but also takes the switch wire from the wall switch as an input and do local switching if needed. When the wall switch is toggled, the switch also sends an MQTT update to domoticz to update the current switch state. The module is located in or near the lamp, so in case of a hotel circuit, it also works.
First test looks promising
Perhaps look at Tasmota..
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Tuesday 21 August 2018 8:12
by SweetPants
Derik wrote: ↑Monday 20 August 2018 23:21
SweetPants wrote: ↑Monday 11 June 2018 19:53
Project Scope:
When entering my house I want to be able to switch the light in the halway automatically between sunset and sunrise. So when the door opens, switch On the light for say 1-2 minutes and switch Off again using dzVentz. But I also want to be able to switch on/off the light using the existing wall switch(es).
This could be done using an extra (ESP8266 driven) relay in parallel with the original wall switch, but then you are not able to switch off the lights anymore with the wall switch and this is not suitable when having a hotel circuit (2 or more switches in series)
This could be solved by buying (expensive) wall switches which most of the time do not fit into the wall box or are totally different from the original.
Solution:
I've created an ESP8266 enabled switch that can be switched using MQTT, but also takes the switch wire from the wall switch as an input and do local switching if needed. When the wall switch is toggled, the switch also sends an MQTT update to domoticz to update the current switch state. The module is located in or near the lamp, so in case of a hotel circuit, it also works.
First test looks promising
Perhaps look at Tasmota..
As said, it's already working fine, so no need for Tasmota
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Wednesday 22 August 2018 14:13
by ronschaeffer
SweetPants wrote: ↑Monday 20 August 2018 18:43
ronschaeffer wrote: ↑Monday 20 August 2018 16:43
Thanks. Have you been happy with the performance?
What performance? It's just a switch and it takes only a few msec to switch either locally or via MQTT
Just meant whether it was working reliably
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Wednesday 22 August 2018 15:47
by SweetPants
ronschaeffer wrote: ↑Wednesday 22 August 2018 14:13
SweetPants wrote: ↑Monday 20 August 2018 18:43
ronschaeffer wrote: ↑Monday 20 August 2018 16:43
Thanks. Have you been happy with the performance?
What performance? It's just a switch and it takes only a few msec to switch either locally or via MQTT
Just meant whether it was working reliably
yup, running since jun 11 and never missed a local or MQTT switch up till now. Have 2 running, working on a third, waiting for some components.
ESP8266 MQTT switch with local on/off and feedback
Posted: Wednesday 22 August 2018 21:24
by Dlanor
SweetPants wrote:
yup, running since jun 11 and never missed a local or MQTT switch up till now. Have 2 running, working on a third, waiting for some components.
Can it also be installed behind a light switch? Dutch version ‘inbouwdoos’?
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Thursday 23 August 2018 9:08
by SweetPants
Dlanor wrote: ↑Wednesday 22 August 2018 21:24
Can it also be installed behind a light switch? Dutch version ‘inbouwdoos’?
Depends on the depth of the 'inbouwdoos', but I don't think so, never tried. Also be aware that the ESP antenna is a PCB antenna and known not to be very good, so placing it behind the original wall switch could give problems.
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Thursday 23 August 2018 10:49
by Antori91
Hello SweetPants,
Could you publish the ESP8266 code you are using for this?
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Thursday 23 August 2018 22:03
by SweetPants
Antori91 wrote: ↑Thursday 23 August 2018 10:49
Hello SweetPants,
Could you publish the ESP8266 code you are using for this?
Send me a PM. Be aware, this is C code using the ESP SDK (2.2.0) directly, so no Arduino IDE or any other platform involved.
Re: ESP8266 MQTT switch with local on/off and feedback
Posted: Monday 10 August 2020 14:13
by srushti
SweetPants wrote: ↑Friday 17 August 2018 14:30
ronschaeffer wrote: ↑Friday 17 August 2018 13:41
Sounds really interesting. Please post some details about your hardware set up to detect the wall switch toggle. Thanks!
Schematic: (The circled part converts the wall switch signal to something the ESP can handle
Feedback_Switch.png
Hardware:
Hardware.jpg
Hello,
I am facing the same issue and I want to update the status of the switch on domoticz when I toggle a wall switch. I am unable to access the Feedback_switch.png and hardware.jpg provided in this quote. Can you please provide me with the same and any additional information will be helpful.