Skip to content

Commit 71d71fb

Browse files
authored
Merge pull request #5474 from tonhuisman/bugfix/MQTT-import-fix-handling
[MQTT] Bugfix: Import wasn't initiated and handled correctly
2 parents 556e376 + 367f4f9 commit 71d71fb

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/src/Globals/Plugins.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,10 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str)
10131013
case PLUGIN_GET_UOM_GROUPS:
10141014
#endif // if FEATURE_TASKVALUE_UNIT_OF_MEASURE
10151015

1016-
// PLUGIN_MQTT_xxx functions are directly called from the scheduler.
1017-
// case PLUGIN_MQTT_CONNECTION_STATE:
1018-
// case PLUGIN_MQTT_IMPORT:
1016+
#if FEATURE_MQTT
1017+
case PLUGIN_MQTT_CONNECTION_STATE:
1018+
case PLUGIN_MQTT_IMPORT:
1019+
#endif // if FEATURE_MQTT
10191020
{
10201021
START_TIMER;
10211022
const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(event->TaskIndex);

src/src/Helpers/PeriodicalActions.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,6 @@ void scheduleNextMQTTdelayQueue() {
322322
}
323323

324324
void schedule_all_MQTTimport_tasks() {
325-
controllerIndex_t ControllerIndex = firstEnabledMQTT_ControllerIndex();
326-
327-
if (!validControllerIndex(ControllerIndex)) { return; }
328-
329325
constexpr pluginID_t PLUGIN_MQTT_IMPORT(PLUGIN_ID_MQTT_IMPORT);
330326

331327
deviceIndex_t DeviceIndex = getDeviceIndex(PLUGIN_MQTT_IMPORT); // Check if P037_MQTTimport is present in the build
@@ -420,9 +416,6 @@ void updateMQTTclient_connected() {
420416
addLogMove(LOG_LEVEL_ERROR, connectionError);
421417
}
422418
MQTTclient_must_send_LWT_connected = false;
423-
} else {
424-
// Now schedule all tasks using the MQTT controller.
425-
schedule_all_MQTTimport_tasks();
426419
}
427420
if (Settings.UseRules) {
428421
if (MQTTclient_connected) {
@@ -431,6 +424,8 @@ void updateMQTTclient_connected() {
431424
eventQueue.add(F("MQTT#Disconnected"));
432425
}
433426
}
427+
// Now schedule all tasks using the MQTT Import plugin.
428+
schedule_all_MQTTimport_tasks();
434429
}
435430
if (!MQTTclient_connected) {
436431
// As suggested here: https://github.com/letscontrolit/ESPEasy/issues/1356

0 commit comments

Comments
 (0)