Skip to content

Set /status LWT topic only once #4696

Closed

Description

@zuckschwerdt

I'm logging all my devices LWT topics (/status /presence /availability etc.) and a change in those topics usually indicates trouble (wifi lost, reboot).

It is surprising that WLED is repeatedly setting the /status LWT topic in normal operation.

The publishMqtt() function sets the LWT topic /status to "online". It is called from updateInterfaces() thus the LWT topic will be set with each change of parameters.

Was that a conscious design decision? Is there a technical or API reason?

Would you be open to a PR which moves

WLED/wled00/mqtt.cpp

Lines 177 to 179 in 25223c4

strlcpy(subuf, mqttDeviceTopic, MQTT_MAX_TOPIC_LEN + 1);
strcat_P(subuf, PSTR("/status"));
mqtt->publish(subuf, 0, true, "online"); // retain message for a LWT

up a few lines into onMqttConnect() -- it's where other projects usually set the LWT.

Activity

  1. blazoncek commented on May 22, 2025

    @blazoncek
    Contributor

    Yes.

  2. linked a pull request that will close this issueChange to set LWT only once #4697on May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions