arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.98k stars 4.77k forks source link

Websend action execution randomly delayed and very inconsistent. #17905

Closed digital-spinner closed 1 year ago

digital-spinner commented 1 year ago

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.

I have

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [X] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua
  Rules output here:
RESULT = {"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":94,"Free":417,"Rules":"ON Switch2#State==2 DO Websend [192.168.102.32] /?device=relay&name=light&command=toggle ENDON"}}
- [X] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
  Console output here:

08:53:39.412 ADE: ACCMODE 0x2D1C00, VRMS 6221316, 6221125, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:40.412 ADE: ACCMODE 0x2D1C00, VRMS 6218538, 6217910, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:41.412 ADE: ACCMODE 0x2D1C00, VRMS 6218244, 6216633, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 29, VAR 0, 0
08:53:42.412 ADE: ACCMODE 0x2D1C00, VRMS 6217546, 6216069, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:43.412 ADE: ACCMODE 0x2D1C00, VRMS 6217880, 6215831, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:44.412 ADE: ACCMODE 0x2D1C00, VRMS 6227744, 6225268, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:45.412 ADE: ACCMODE 0x2D1C00, VRMS 6217980, 6215273, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:46.412 ADE: ACCMODE 0x2D1C00, VRMS 6215761, 6212896, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:47.412 ADE: ACCMODE 0x2D1C00, VRMS 6218623, 6214911, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:48.412 ADE: ACCMODE 0x2D1C00, VRMS 6212297, 6208432, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:49.411 ADE: ACCMODE 0x2D1C00, VRMS 6221049, 6217161, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:49.621 RUL: SWITCH2#STATE==2 performs "Websend [192.168.102.32] /?device=relay&name=light&command=toggle"
08:53:49.623 SRC: Rule
08:53:49.626 CMD: Grp 0, Cmd 'WEBSEND', Idx 1, Len 57, Pld -99, Data '[192.168.102.32] /?device=relay&name=light&command=toggle'
08:53:50.412 ADE: ACCMODE 0x2D1C00, VRMS 6217970, 6213865, Period 4472, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:51.264 RSL: RESULT = {"WebSend":"Done"}
08:53:51.412 ADE: ACCMODE 0x2D1C00, VRMS 6218963, 6215299, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:51.792 RUL: SWITCH2#STATE==2 performs "Websend [192.168.102.32] /?device=relay&name=light&command=toggle"
08:53:51.794 SRC: Rule
08:53:51.797 CMD: Grp 0, Cmd 'WEBSEND', Idx 1, Len 57, Pld -99, Data '[192.168.102.32] /?device=relay&name=light&command=toggle'
08:53:52.273 RSL: RESULT = {"WebSend":"Done"}
08:53:52.412 ADE: ACCMODE 0x2D1C00, VRMS 6217980, 6214812, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:52.576 RUL: SWITCH2#STATE==2 performs "Websend [192.168.102.32] /?device=relay&name=light&command=toggle"
08:53:52.578 SRC: Rule
08:53:52.581 CMD: Grp 0, Cmd 'WEBSEND', Idx 1, Len 57, Pld -99, Data '[192.168.102.32] /?device=relay&name=light&command=toggle'
08:53:53.412 ADE: ACCMODE 0x2D1C00, VRMS 6216798, 6213801, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:54.411 ADE: ACCMODE 0x2D1C00, VRMS 6216370, 6213555, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:55.411 ADE: ACCMODE 0x2D1C00, VRMS 6217656, 6215283, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:56.139 RSL: RESULT = {"WebSend":"Done"}
08:53:56.412 ADE: ACCMODE 0x2D1C00, VRMS 6217441, 6216623, Period 4473, 4472, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:57.412 ADE: ACCMODE 0x2D1C00, VRMS 6214875, 6214653, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:58.412 ADE: ACCMODE 0x2D1C00, VRMS 6217821, 6218933, Period 4473, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:59.412 ADE: ACCMODE 0x2D1C00, VRMS 6215012, 6216545, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:53:59.897 WIF: Checking connection...
08:54:00.412 ADE: ACCMODE 0x2D1C00, VRMS 6212327, 6214222, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:01.412 ADE: ACCMODE 0x2D1C00, VRMS 6214666, 6217131, Period 4473, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:02.411 ADE: ACCMODE 0x2D1C00, VRMS 6211843, 6214787, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:03.412 ADE: ACCMODE 0x2D1C00, VRMS 6208699, 6212453, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:04.411 ADE: ACCMODE 0x2D1C00, VRMS 6211736, 6215460, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:05.412 ADE: ACCMODE 0x2D1C00, VRMS 6204987, 6208874, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:05.485 RUL: SWITCH2#STATE==2 performs "Websend [192.168.102.32] /?device=relay&name=light&command=toggle"
08:54:05.487 SRC: Rule
08:54:05.490 CMD: Grp 0, Cmd 'WEBSEND', Idx 1, Len 57, Pld -99, Data '[192.168.102.32] /?device=relay&name=light&command=toggle'
08:54:06.162 RSL: RESULT = {"WebSend":"Done"}
08:54:06.412 ADE: ACCMODE 0x2D1C00, VRMS 6215269, 6219235, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:07.412 ADE: ACCMODE 0x2D1C00, VRMS 6212680, 6216595, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:08.412 ADE: ACCMODE 0x2D1C00, VRMS 6214519, 6218576, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:09.412 ADE: ACCMODE 0x2D1C00, VRMS 6214741, 6218729, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:10.411 ADE: ACCMODE 0x2D1C00, VRMS 6215949, 6220052, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 29, 28, VAR 0, 0
08:54:11.412 ADE: ACCMODE 0x2D1C00, VRMS 6210566, 6214421, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:12.412 ADE: ACCMODE 0x2D1C00, VRMS 6211752, 6215768, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:13.411 ADE: ACCMODE 0x2D1C00, VRMS 6211493, 6215436, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:14.412 ADE: ACCMODE 0x2D1C00, VRMS 6211197, 6215207, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:15.411 ADE: ACCMODE 0x2D1C00, VRMS 6208395, 6212401, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:16.148 WIF: Sending Gratuitous ARP
08:54:16.412 ADE: ACCMODE 0x2D1C00, VRMS 6213043, 6217058, Period 4476, 4476, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:17.412 ADE: ACCMODE 0x2D1C00, VRMS 6210946, 6214878, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:18.412 ADE: ACCMODE 0x2D1C00, VRMS 6215689, 6219635, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:19.412 ADE: ACCMODE 0x2D1C00, VRMS 6213383, 6217179, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:20.412 ADE: ACCMODE 0x2D1C00, VRMS 6206764, 6210699, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:20.421 WIF: Checking connection...
08:54:21.412 ADE: ACCMODE 0x2D1C00, VRMS 6210756, 6214262, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:22.412 ADE: ACCMODE 0x2D1C00, VRMS 6205190, 6208590, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:23.412 ADE: ACCMODE 0x2D1C00, VRMS 6212777, 6215979, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:24.412 ADE: ACCMODE 0x2D1C00, VRMS 6209925, 6213291, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:25.412 ADE: ACCMODE 0x2D1C00, VRMS 6212914, 6216067, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:26.152 RSL: STATE = {"Time":"2023-02-07T08:54:26","Uptime":"0T08:56:12","UptimeSec":32172,"Heap":21,"SleepMode":"Normal","Sleep":0,"LoadAvg":999,"MqttCount":0,"POWER1":"OFF","POWER2":"OFF","Wifi":{"AP":1,"SSId":"DigitallHOME-R","BSSId":"C0:C9:E3:3B:5A:4E","Channel":7,"Mode":"11n","RSSI":94,"Signal":-53,"LinkCount":1,"Downtime":"0T00:00:03"}}
08:54:26.164 RSL: SENSOR = {"Time":"2023-02-07T08:54:26","Switch1":"ON","Switch2":"ON","ANALOG":{"Temperature":57.3},"ENERGY":{"TotalStartTime":"2023-02-06T23:57:43","Total":0.107,"Yesterday":0.095,"Today":0.011,"Period":[0,0],"Power":[0,0],"ApparentPower":[0,0],"ReactivePower":[0,0],"Factor":[0.00,0.00],"Frequency":0,"Voltage":0,"Current":[0.000,0.000]},"TempUnit":"C"}
08:54:26.412 ADE: ACCMODE 0x2D1C00, VRMS 6211714, 6214904, Period 4475, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:27.412 ADE: ACCMODE 0x2D1C00, VRMS 6212059, 6214937, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:28.412 ADE: ACCMODE 0x2D1C00, VRMS 6209394, 6212345, Period 4475, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:29.411 ADE: ACCMODE 0x2D1C00, VRMS 6212651, 6215260, Period 4475, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:30.412 ADE: ACCMODE 0x2D1C00, VRMS 6214536, 6217387, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:31.412 ADE: ACCMODE 0x2D1C00, VRMS 6214767, 6218055, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:32.412 ADE: ACCMODE 0x2D1C00, VRMS 6213312, 6216742, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:33.411 ADE: ACCMODE 0x2D1C00, VRMS 6212988, 6216124, Period 4474, 4474, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:34.411 ADE: ACCMODE 0x2D1C00, VRMS 6211161, 6214338, Period 4474, 4475, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0
08:54:35.412 ADE: ACCMODE 0x2D1C00, VRMS 6211718, 6215370, Period 4473, 4473, IRMS 1773, 1773, WATT 0, 0, VA 28, 28, VAR 0, 0

TO REPRODUCE

Steps to reproduce the behavior:

// wipe current configuration but retain WiFi credentials Reset 4

// set theme color WebColor {"WebColor":["#eaeaea","#252525","#4f4f4f","#000000","#dddddd","#65c115","#1f1f1f","#ff5661","#008000","#faffff","#1fa3ec","#0e70a4","#d43535","#931f1f","#47c266","#5aaf6f","#faffff","#999999","#eaeaea"]}

// apply template and best settings

Backlog Template {"NAME":"Shelly 2.5","GPIO":[56,0,17,0,21,83,0,0,6,82,5,22,156],"FLAG":2,"BASE":18};
 SwitchMode1 6; SwitchMode2 6; Backlog SetOption0 0; SetOption3 0; PowerOnState 0; SetOption32 20; SaveData 0; Module 0; Restart 1

// apply rule to be used with pushbutton 2

Rule1 ON Switch2#State==2 DO Websend [192.168.102.32] /?device=relay&name=light&command=toggle ENDON
Rule1 1

Use the switch 2 to operate.. The action execution randomly delays. Sometimes is missing sometimes it executes even after couple of seconds.

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

Web send should be executed with minimum possible delay, preferably instantaneously but it is not. Blebox device used before this one was behaving like expected.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

I need to control another device which can accept HTTP GET requests. Since my Blebox device died I switched to Shelly 2.5 and Tasmota 12.3.1 for it (also tested with 9.2.0) but the described issue raised. I have also tested WebQuery command and it behaves in the same way.

(Please, remember to close the issue when the problem has been addressed)

Jason2866 commented 1 year ago

Tasmota is designed to be used with mqtt. Do not expect near real time behaviour when using http.

digital-spinner commented 1 year ago

Hola, wait a minute! I didn't say anything about the real time behavior and don't be rude man. The WebSend is just slow as hell comparing to other solutions and I'm not even mentioning the random delay of it's processing capabilities and occasional connection issues of that. If this is the case just remove the whole websend / webquery stuff from it so there will be no confusion of any kind. I just bought those devices only because of this functionality. And yea, I can go with MQTT later, but I hope you understand the confusion?

And the last one thing at the end: Tasmota is great without the doubts and it's power comes from "simplicity".

barbudor commented 1 year ago

Hi @digital-spinner I see 2 parts from you issue

I would suggest first to treat them separately starting with the rule If you replace the websend by something purely internal to Tasmota like incrementing a variable or toggling a native relay on gpio, what is your experience? Do you see delay? Randomness?

Regarding the delay on websend (WebQuery could seem more logical for non tasmota target although it's a matter or syntax as it's the same code behind) you would need an analysis at a network level which is not easy to qualify if the delay is from Tasmota or the device or the network

sfromis commented 1 year ago

My experience testing WebSend (or the better implementation WebQuery) is that I get quick reactions, as long as the server responds quickly, but any latency in server (or network) slows down processing, just like when I use a browser and a web server. WebSend is not "fire and forget", but depends on getting a response, unlike the asynchronous MQTT which works much better for such expectations.

I did not see any "rude" behavior from Jason, you should expect different styles from different people, including short matter-of-fact responses. And it is correct that http is not at the core of Tasmota design, more like an added tangent without focusing on tuning this part.

digital-spinner commented 1 year ago

If i just type the Websend in the console it has the same random delay behave. I mean, the first time after long period of not doing anything it usually fires immediately, but after even like 5 seconds next press (or next console command) is a lotery - it may execute like within 2-3 seconds or it will execute like after 5 or so. It looks like it can't be used more often than once per 10 seconds at least. And again it doesn't happen with some other devices (Blebox with thier API capabilities) so that is why I'm mentioning it here at first place. It is a possibility to improve if of course can be done.

barbudor commented 1 year ago

If I understand well what you describe, it's mostly pointing in delay in the whole http communication Definitively needs network analysis (tcpdump/wireshark). If you have an http workflow from another device than Tasmota, both need capture to allow comparison

Improvement can only occur if something missing is identified, and identification can only come from your size (your network, you device)

digital-spinner commented 1 year ago

I think the issue is with scheduling internal execution with Tasmota itself not the network issues, but for my curiosity I will check another Tasmota device if this is a case and let know if anything is changed for worse or better but.. when I click toggle on web panel it reacts immediately for those power outputs which it has (all my devices reacts momentarily), also relays reacts immediately on buttons reactions. Maybe there is a way to prioritize the HTTP over MQTT (an option switch for that) so the HTTP will have a precedence if it consumes some CPU cycles which is less and less after each action because MQTT is working or some other stuff (but I have the MQTT disable on my devices currently).

Anyway it makes sense to have a low priority for the HTTP API support if the MQTT solution is aimed for speed and reliability.. I think I'm gonna get rid of the HTTP devices and put the MQTT to use but i need some time to do that and I have already like 3 other projects to work on :-( And the HTTP API is so simple and easy to use..

sfromis commented 1 year ago

The "low priority" for HTTP is not about scheduling or CPU cycles, but about implementation. It is "tacked on", but by far not seen as a "primary strategy"

Not much has been done to create "optimal" implementations of using HTTP, even on the inherently slower terms of using this protocol, which is based on starting and closing sessions per request, instead of MQTT using a persistent session, leading to fewer network round trips.

As MQTT can be "fire and forget", Tasmota will not be delayed by the time it takes to serve the message, unlike HTTP. OTOH, a request/response strategy is more cumbersome with MQTT, as this is not part of the protocol.

digital-spinner commented 1 year ago

@sfromis thanks for the explanation, good to know that. Just one additional question to that - just wonder about one thing (don't know how it is done here) are those MQTT messeges acknowledged or not (sent by Tasmota). I know it can be both ways with MQTT right? So the brocker ACK can also be problematic if I understand correctly. Also MQTT uses TCP so the connection itself needs to be acknowledged.

sfromis commented 1 year ago

While MQTT uses TCP, each client has one persistent connection while available, until outages of either end or network. Ideally up to years, but at the least it should be hours.

As Tasmota only uses QoS 0 "at most once" with MQTT, delivery is not assured.

The minimal QoS level is zero. This service level guarantees a best-effort delivery. There is no guarantee of delivery. The recipient does not acknowledge receipt of the message and the message is not stored and re-transmitted by the sender. QoS level 0 is often called “fire and forget” and provides the same guarantee as the underlying TCP protocol.

In practice, HTTP provides no better delivery assurance, but the requestor does have the option of checking for a response.

digital-spinner commented 1 year ago

Thank you!

barbudor commented 1 year ago

I just played alittle game between an ESP32-DevKit and an ESP8266-NoceMCU Each have a relay Each have a rule like on power1#state do websend [ip of the ohter] power toggle endon That's the Tamsota version of the stupid machine

Here is the log I have:

21:58:07.387 RUL: POWER1#STATE performs "websend [192.168.168.195] power toggle"
21:58:07.508 MQT: stat/esp32dev3/WEBQUERY = {"WebQuery":{"POWER":"OFF"}}
21:58:07.516 MQT: stat/esp32dev3/WEBSEND = {"WebSend":"Done"}
21:58:07.595 MQT: stat/esp32dev3/POWER = {"POWER":"ON"}
21:58:07.601 MQT: stat/esp32dev3/POWER = ON (retained)
21:58:07.640 RUL: POWER1#STATE performs "websend [192.168.168.195] power toggle"
21:58:07.753 MQT: stat/esp32dev3/WEBQUERY = {"WebQuery":{"POWER":"ON"}}
21:58:07.761 MQT: stat/esp32dev3/WEBSEND = {"WebSend":"Done"}
21:58:07.839 MQT: stat/esp32dev3/POWER = {"POWER":"OFF"}
21:58:07.842 MQT: stat/esp32dev3/POWER = OFF (retained)
21:58:07.875 RUL: POWER1#STATE performs "websend [192.168.168.195] power toggle"
21:58:08.014 MQT: stat/esp32dev3/WEBQUERY = {"WebQuery":{"POWER":"OFF"}}
21:58:08.023 MQT: stat/esp32dev3/WEBSEND = {"WebSend":"Done"}
21:58:08.107 MQT: stat/esp32dev3/POWER = {"POWER":"ON"}
21:58:08.112 MQT: stat/esp32dev3/POWER = ON (retained)
21:58:08.146 RUL: POWER1#STATE performs "websend [192.168.168.195] power toggle"
21:58:08.263 MQT: stat/esp32dev3/WEBQUERY = {"WebQuery":{"WebQuery":}
21:58:08.272 MQT: stat/esp32dev3/WEBSEND = {"WebSend":"Done"}

So the round-trip-time is less than 300 ms for one tasmota to send the command and the other to sendback the command And roughly less htan 100ms between the "WebSend Done" and receiving the reply command which is rule execution + Websend execution.

I don't see any performance problem on Tasmota The results are consistent mnutes after minutes

So as sfromis pointed out, it's most likely due to some delay in the network or the other device

Now, we don't know what your Shelly is doing at the same time, so can't judge is tasmota could be busy doing something else. My devkit+nodemcu are only doing that

May be you can try same test between your Shelly and anohter Tamsota ?

barbudor commented 1 year ago

And for the completness of the test, let's do it replacing the WebSend by a publish cmnd/othertopic/power toggle

22:05:33.311 MQT: cmnd/nodemcu/power = toggle
22:05:33.487 MQT: stat/esp32dev3/POWER = {"POWER":"ON"}
22:05:33.490 MQT: stat/esp32dev3/POWER = ON (retained)
22:05:33.502 RUL: POWER1#STATE performs "publish cmnd/nodemcu/power toggle"
22:05:33.509 MQT: cmnd/nodemcu/power = toggle
22:05:33.687 MQT: stat/esp32dev3/POWER = {"POWER":"OFF"}
22:05:33.690 MQT: stat/esp32dev3/POWER = OFF (retained)
22:05:33.702 RUL: POWER1#STATE performs "publish cmnd/nodemcu/power toggle"
22:05:33.709 MQT: cmnd/nodemcu/power = toggle
22:05:33.788 MQT: stat/esp32dev3/POWER = {"POWER":"ON"}
22:05:33.795 MQT: stat/esp32dev3/POWER = ON (retained)
22:05:33.807 RUL: POWER1#STATE performs "publish cmnd/nodemcu/power toggle"
22:05:33.813 MQT: cmnd/nodemcu/power = toggle
22:05:33.987 MQT: stat/esp32dev3/POWER = {"POWER":"OFF"}
22:05:33.994 MQT: stat/esp32dev3/POWER = OFF (retained)
22:05:34.002 RUL: POWER1#STATE performs "publish cmnd/nodemcu/power toggle"
22:05:34.010 MQT: cmnd/nodemcu/power = toggle
22:05:34.083 MQT: stat/esp32dev3/POWER = {"POWER":"ON"}
22:05:34.091 MQT: stat/esp32dev3/POWER = ON (retained)
22:05:34.102 RUL: POWER1#STATE performs "publish cmnd/nodemcu/power toggle"
22:05:34.106 MQT: cmnd/nodemcu/power = toggle

200ms round-trip-time So a ~30% performance improvement of MQTT over HTTP Which is not suprising based on the asynchonicity of MQTT vs HTTP

barbudor commented 1 year ago

image

digital-spinner commented 1 year ago

OK, thank you.

One thing I have tested additionally is another Shelly 2 with Tasmota 9.2.0 and it behave in the same way. There is also a random lag after button press. For comparison Blebox switches also are executing api endpoint in the same way but I did not noticed any random lag with those. Of course when I click like crazy 3 times fast then even those will loose one payload etc. but there was no random lag, it was actually expected after multiple presses (I guess it was doing also something) but not like in my Shellies now.

I think I will migrate to MQTT someday, for now I can live with that as it is.

If you can point me what network tests I can do than I will try to do it. My network has fiber WAN connection attached to OPNSense gateway, which serves through the switch 3 APs and some other cable clients. Never had an issue with that - it is rock solid and serves also as a VPN gateway (this is the main reason why it is at the first place). My work laptops have 200+Mbps over WiFi in every case and the workstation easily can utilize 930Mbps over cable. The DNS is dynamically managed but I set the manual assignations, so every device gets its own IP address. Ah, the subnet is 22 if this matter. The APs are just serving WiFi in FAST ROAM mode using OpenWRT firmware and doing nothing more. I have over 40 wifi IOT devices if I remember. I hope that I won't start glowing any soon.

barbudor commented 1 year ago

The best would be to be able to do tcpdump/wirechark captures (I believe I already said that above) But if the addressed device is an embedded device and not a server, I don't know how to achieve that In some case, it is possible to use some wifi card in PCs in "promiscuous mode" which is a kind of "spy" mode where the would capture everything that goes on the wifi network. But my understanding that this feature is not available with every wifi card

digital-spinner commented 1 year ago

OK, one observation extra to that.. When I press both buttons simultaneously, then the random delay applies for both, the physical one and the WebSend wired button also. There is definitely some issue here.

When I have both buttons wired physically (without any rules) then there is no delay.