MQTT refresh rate for "Generic - MQTT Import"

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
InterestedInESP
New user
Posts: 8
Joined: 29 Nov 2020, 22:11
Location: Germany

MQTT refresh rate for "Generic - MQTT Import"

#1 Post by InterestedInESP » 07 Apr 2021, 09:29

Hello,
I couldnt find answers in the forum, maybe not using the right key words, but I tried... So here is my new question:

Using an D1 mini for collecting some sensor data and publishing it to ioBroker (running on an RPi) via MQTT, I also want to switch the D1 minis outputs from the iobroker depending on circumstances the D1 mini does not know about.

So I defined a new device "Generic - MQTT import" and created a topic in the ioBroker and in the "Generic - MQTT import" settings of ESP Easy as well. In between it works, but with a strange effect for me:

When setting the the value of <MQTT topic>/GPIO/2 to zero "0" in ioBroker the LedBuiltin on the D1 mini immediately goes on. But nevertheless the shown value in the "Device" menu keeps on the value before. When then up to 30 seconds passed the value will show the real current "0".

Same is when when switching off by setting the value of <MQTT topic>/GPIO/2 to zero "1" in ioBroker, the Led is switched off immediately but the value in "Device" menu keeps the old "0" until it is refreshed about 20...30 seconds later.

Where does this delay come from? I didn't find any possibility to set a refresh rate or intervall for the MQTT import in ESP Easy.
Becaus the reaction of the D1 mini is immediately I think the ioBroker has sent its message correctly and in my opinion the refresh must be delayed somewhere in the ESP easy...

Hint: the other devices (physical connected temperature and humidtiy sensors SHT35 and DHT22 for experimenting) are set to send new values to the controller (ioBrokers MQTT server) every 30 seconds. Maybe there is an influence?

Thanks a lot to anybody who can help!

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT refresh rate for "Generic - MQTT Import"

#2 Post by TD-er » 07 Apr 2021, 10:12

The delay in the "Devices" tab of the web browser is caused by the fact the JavaScript does need to 'pull' the values from the ESP.
It periodically does a HTTP GET to fetch a JSON structure.
In this JSON, there is a TTL value, which tells the JavaScript when to reload the JSON again.
This TTL is the lowest "interval" value of all enabled tasks.
So if you add just a single task with for example the sysinfo plugin and set that interval to 1 sec, then you will see faster updates.

If you use the rules, you will get an event when the MQTT import task receives a new value and you can immediately act on it.
But the web UI is still relying on periodically updating the values as described above, so you will not see updates appear faster than once a second... if you set at least one task to that interval.

InterestedInESP
New user
Posts: 8
Joined: 29 Nov 2020, 22:11
Location: Germany

Re: MQTT refresh rate for "Generic - MQTT Import"

#3 Post by InterestedInESP » 07 Apr 2021, 12:09

Thanks @TD-er for the fast reply!

Now I understand that you confirm, that the MQTT Commands will be processed and act immediately while only the display refresh of the values in the WEB UI is delayed.

Okay, knowing that fact it will not harm my project. It was only a little confusing for me in the last time, because I couldn't find out if it worked or not. So I changed too fast some settings where I supposed the root of my problems and brought in new problems that way instead of solving and so on... I should have been more patient and give the UI a little time...


From my side the problem is solved now. Thanks again!

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests