Wi-Fi HTTP Switch
Posted: Friday 17 June 2016 22:08
Hi,
I'm building with an ESP8266 (board arduino like but with onboard WiFi) a controller for a relay to swtich some lights.
The project also allows to switch the light from a phisical switch on the wall.
Domotics is configure to open an HTTP link when the light is on and anotherone when the light goes off.
For fallback reason (ex WiFi or Domoticz not working) the ESP8266 is configured this way:
1) if the phisical switch is triggered I want the ESP8266 to change autonomously the relay state and after that send the HTTP request to JSON API to inform of the changed state
2) if a HTTP request is recived from domoticz instantly change the relay state
Now my problem: if I trigger the phisical switch this is appening:
1) the light goes on
2) ESP8266 then sends the HTTP JSON request to domoticz
3) Domoticz receive the switch toggle
4) Domoticz sends a HTTP Request to ESP8266 because the light status has changed
5) ESP8266 switch off the light
So I'm in a cycle with no end. If I toggle the swtich directly from domoticz works like a charm. Everything works good also if I disable the request from ESP8266 to Domoticz to inform the changed state.
Is there a way to get out from this?
This is my domoticz configuration

I'm building with an ESP8266 (board arduino like but with onboard WiFi) a controller for a relay to swtich some lights.
The project also allows to switch the light from a phisical switch on the wall.
Domotics is configure to open an HTTP link when the light is on and anotherone when the light goes off.
For fallback reason (ex WiFi or Domoticz not working) the ESP8266 is configured this way:
1) if the phisical switch is triggered I want the ESP8266 to change autonomously the relay state and after that send the HTTP request to JSON API to inform of the changed state
2) if a HTTP request is recived from domoticz instantly change the relay state
Now my problem: if I trigger the phisical switch this is appening:
1) the light goes on
2) ESP8266 then sends the HTTP JSON request to domoticz
3) Domoticz receive the switch toggle
4) Domoticz sends a HTTP Request to ESP8266 because the light status has changed
5) ESP8266 switch off the light
So I'm in a cycle with no end. If I toggle the swtich directly from domoticz works like a charm. Everything works good also if I disable the request from ESP8266 to Domoticz to inform the changed state.
Is there a way to get out from this?
This is my domoticz configuration
