Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MQTT] Don't subscribe to empty topics #5240

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/_P037_MQTTImport.ino
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,10 @@ bool MQTTSubscribe_037(struct EventStruct *event)
for (uint8_t x = 0; x < VARS_PER_TASK; x++) {
String subscribeTo = P037_data->getFullMQTTTopic(x);

if (!subscribeTo.isEmpty()) {
parseSystemVariables(subscribeTo, false);
parseSystemVariables(subscribeTo, false);
subscribeTo.trim();

if (!subscribeTo.isEmpty()) {
tonhuisman marked this conversation as resolved.
Show resolved Hide resolved
if (MQTTclient.subscribe(subscribeTo.c_str())) {
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
addLog(LOG_LEVEL_INFO, strformat(F("IMPT : [%s#%s] subscribed to %s"),
Expand Down
12 changes: 8 additions & 4 deletions src/src/ESPEasyCore/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,15 @@ bool MQTTConnect(controllerIndex_t controller_idx)
String subscribeTo = ControllerSettings->Subscribe;

parseSystemVariables(subscribeTo, false);
MQTTclient.subscribe(subscribeTo.c_str());
subscribeTo.trim();

if (loglevelActiveFor(LOG_LEVEL_INFO))
{
addLogMove(LOG_LEVEL_INFO, concat(F("Subscribed to: "), subscribeTo));
if (!subscribeTo.isEmpty()) {
MQTTclient.subscribe(subscribeTo.c_str());

if (loglevelActiveFor(LOG_LEVEL_INFO))
{
addLogMove(LOG_LEVEL_INFO, concat(F("Subscribed to: "), subscribeTo));
}
}

updateMQTTclient_connected();
Expand Down
Loading