Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
14.54k stars 3.11k forks source link

mqtt (wled/device/status) status info takes a long time to update #3576

Closed viktor6 closed 1 month ago

viktor6 commented 9 months ago

What happened?

mqtt status takes a long time to update esp8266 wled/wled/status 30 seconds esp32 wled/wled/status 2 minutes which is very long

To Reproduce Bug

on/off esp32 wemos D1

Expected Behavior

30 c

Install Method

Binary from WLED.me

What version of WLED?

Installed version: WLED 0.14.0 (ESP32-D0WDQ6 build 2310130)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

No response

Anything else?

On esp8266 it makes a status update from offline to online in 30 seconds On esp32 it makes a status update from offline to online in 2 minutes

Code of Conduct

blazoncek commented 9 months ago

Message with topic wled/device/status is a retained message which is never updated (unless reconnection to MQTT occurs). It has a LWT with value of "offline". This is by design.

viktor6 commented 9 months ago

in esp 6682 it goes from offline to online status faster, which takes 20 seconds

blazoncek commented 9 months ago

Re-read my response. Please. It may be re-broadcast when WLED state updates (along with vtopic) which can take fom 0.1s to infinity.

viktor6 commented 9 months ago

but on my esp32 it updates consistently in 2 minutes. I tried 3 different esp32s and more than once

dosipod commented 9 months ago

in esp 6682 it goes from offline to online status faster, which takes 20 seconds

The offline /online does not mean your unit is off/on , it means your unit is disconnecting from mqtt , the simple way I trap on /off is by listening for the wled/wledunit/g if that is 0 then it is off else it is on image

viktor6 commented 9 months ago

I need to track when wled appears on the network and for further automation

dosipod commented 9 months ago

Okay i so what you mean when you listed on/off you actually mean remove power or make it offline from the network
image I can see use case for car garage

viktor6 commented 9 months ago

turn off the power and turn on the power 5 v , then the status will be online in 2 minutes

dosipod commented 9 months ago

I also see around two minutes , which is the time it takes to reconnect to mqtt ..etc , i think trapping for IP might be better but sure image

viktor6 commented 9 months ago

And on esp8266 it is about 30 seconds

blazoncek commented 9 months ago

You don't seem to understand MQTT. /status topic is retained with LWT set. When WLED device is without power you will receive LWT (which is "offline"), when it is powered on you will receive "online". WLED will not re-broadcast it on its own but only together with any other state change (see example below).

Screenshot 2023-12-08 at 20 33 16

dosipod commented 9 months ago

And on esp8266 it is about 30 seconds

I also got the same strange result you pointed out when I tested with esp8266 , it will be reconnected after i remove power in very much less time then esp32 . Must be something with mqtt re-connection on esp32 could be heavy after power down , I did not even trap for offline /online but only for wled/WLED/g as you see in the example which is the same test I did on esp32

image

dosipod commented 9 months ago

@viktor6
I found something you may want to try , once I changed the MQTT_KEEP_ALIVE_TIME value in wled00/mqtt.cpp the status change on esp32 is much faster now , Bin and change is here https://github.com/dosipod/wled-dos-mod/actions/runs/7151014493 image

github-actions[bot] commented 1 month ago

Hey! This issue has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs. Thank you for using WLED! ✨