Skip to content

Set /status LWT topic only once #4696

@zuckschwerdt

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.

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