Page 1 of 1
How to dummy device ACK work (esp8266)
Posted: Friday 02 November 2018 14:05
by pit34
Hello everyone,
It's been a while since I search but I can not find an answer.
How the ACK works, in a configuration with t dummy WIFI device (example for example). Is it just based on the returned code http 200? Is there an ACK like on MySensor?
I try to understand ACK in both side : dommoticz http request send to esp8266 and esp8266 http request send to domoticz
I need to understand to finish the code of my esp8266.
Thank you

Re: How to dummy device ACK work (esp8266)
Posted: Friday 02 November 2018 15:13
by SweetPants
In domoticz there is nothing (as far as i know) that will send an ACK to your ESP, there is always something of a gateway in between your sensor and domoticz (like MySensors). I'm not sure what you mean with 'I need to understand to finish the code of my esp8266', do you write your own code?
Re: How dummy device ACK work (esp8266) ?
Posted: Friday 02 November 2018 19:59
by pit34
Thanks for your answer @SweetPants.
So if Domoticz doesn't use ACK with Dummy device on TCP/IP, i assume there is only HTTP code 200 to tell Domoticz that request has been received ?
I try to understand how to implement ACK on dummy device to be sure that, for example, switch state is really switched on device (when sending command from Domoticz server to dummy device) or on Domoticz GUI (when sending command from dummy device to Domoticz server).
By 'I need to understand to finish the code of my esp8266' i mean that i'm writing my own code for ESP8266 with arduino IDE.
Code is working, i can switch relay state by Domoticz GUI, or locally on device and change switch state on Domoticz GUI. But sometime request is lost and information is not received by target. So Domoticz switch state and relay state are different =/
Re: How to dummy device ACK work (esp8266)
Posted: Saturday 03 November 2018 15:00
by philchillbill
I just wrote a wiki entry on how to use an external perl script to implement what you're looking for (I think). It sends a command to a WiFi device like a Sonoff and polls the Sonoff to make sure it actually received the command. If not, it will resend. Take a look and see if it will do what you want:
https://www.domoticz.com/wiki/Sonoff_-_ ... _switching
Re: How to dummy device ACK work (esp8266)
Posted: Saturday 03 November 2018 16:08
by SweetPants
@philchillbill, He is writing his own SW so probably has to implement something at the switchend that makes it able to read back the switch state.
@pit34, maybe switch to ESPeasy and implement philchillbill's script.?
I myself use MQTT to switch my relais and use 'retained' mode. After WiFi disconnect/connect, the broker will send the latest command to the switch again. As a failsafe I update domoticz on domoticz/in with an update only command: MQTT: Topic: domoticz/in, Message: {"command":"udevice","idx":141,"nvalue":0} So if I locally switch the relais, domoticz is updated too
Re: How to dummy device ACK work (esp8266)
Posted: Sunday 04 November 2018 13:52
by pit34
I think i can try somethings like your script @philchillbill. Write a domoticz script in lua to manage request and acknowledgement and call it with "script://" instead of "http://" in action ON/OFF case. This should do the job for Domoticz to device command.
I just wonder if triggered Domoticz switch's by external script (not in script://) will trigger the Action ON/OFF "script://" too.
To manage device to Domoticz command, i will try to use Domoticz response (
https://www.domoticz.com/wiki/Domoticz_ ... s#Response).
I will read about MQTT too. It seem to be a simple and good solution too.
Thanks

Re: How to dummy device ACK work (esp8266)
Posted: Sunday 04 November 2018 19:13
by philchillbill
pit34 wrote:
I just wonder if triggered Domoticz switch's by external script (not in script://) will trigger the Action ON/OFF "script://" too.
You can always use a JSON call from your script to update the Domoticz switch in question ‘externally’. See the wiki for the api/json formats.
Sent from my iPhone using Tapatalk
Re: How to dummy device ACK work (esp8266)
Posted: Sunday 04 November 2018 23:39
by pit34
Yes. I will make some test.
I have read somes documentation about MQTT and i think it's may be a good way to have unfailing domoticz network.
With QoS level set to 1 or 2 on MQTT gateway, ACK is enable and communication between devices and MQTT gateway must be unfailing.
With MQTT gateway (like Mosquitto) on same device that Domoticz, communication between MQTT gateway and Domoticz should be unfailing too.
And i will not have to write complete ad hoc solution..
I will read more about this
Thanks

.
Re: How to dummy device ACK work (esp8266)
Posted: Monday 05 November 2018 9:07
by SweetPants
pit34 wrote: ↑Sunday 04 November 2018 23:39
With QoS level set to 1 or 2 on MQTT gateway, ACK is enable and communication between devices and MQTT gateway must be unfailing.
Make sure your MQTT library for the ESP supports QOS1 and/or 2. Not all of them do.
Re: How to dummy device ACK work (esp8266)
Posted: Monday 05 November 2018 22:51
by pit34
SweetPants wrote: ↑Monday 05 November 2018 9:07
pit34 wrote: ↑Sunday 04 November 2018 23:39
With QoS level set to 1 or 2 on MQTT gateway, ACK is enable and communication between devices and MQTT gateway must be unfailing.
Make sure your MQTT library for the ESP supports QOS1 and/or 2. Not all of them do.
Yes. I have read some documentations and i think i will try "Homie for ESP8266" library. This supports QOS1 with retained messages.
So MQTT device to/from MQTT gateway communication can be unreliable (wireless network) but should be unfailing (Homie for ESP8266 with QOS1 and retained message von device side + Mosquitto gateway side).
MQTT gateway to/from Domoticz controller should be reliable and unfailing (wired network).
Now, i am just looking for give error feedback to Domoticz with Mosquitto. For example: Domoticz send command to Mosquitto, but switch device (relay, etc..) is not online (wireless problem, etc..).
Mosquitto must give error feedback to Domoticz on communication error to hold sync between Domoticz virtual switches and physical switches.
It's begin to smell good

.
Thanks !
Re: How to dummy device ACK work (esp8266)
Posted: Sunday 11 November 2018 13:03
by pit34
Hi everybody.
So i have finally found a simple way to hold Domoticz and ESP8266 switchs sync.
It's simple to install and use. And avoid to write a lot of code.
You need to :
This way, you will be able to :
- Hold sync between physical and virtual devices,
- Auto-discover devices and avoid setup time in Domoticz,
- Configure ESP8266 devices on their own webpage and avoid configure time
Thinking it's the fastest and easiest way to setup Domoticz / MQTT / ESP8266 devices installation
