From a308b0b651f345b0902e8abbed78e4aafca63a84 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 14 Nov 2021 01:02:43 +0100 Subject: [PATCH] [Domoticz] Only incoming MQTT on tasks with controller linked (#3829) As described on [the forum](https://www.letscontrolit.com/forum/viewtopic.php?f=6&t=8825) Fixes: #3829 --- requirements.txt | 2 +- src/_C002.ino | 4 +++- src/_C005.ino | 8 ++++---- src/_C006.ino | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4d7466d30..d010247cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,7 @@ MarkupSafe==2.0.1 marshmallow==3.14.0 packaging==21.0 pathtools==0.1.2 -platformio>=5.2.2 +platformio>=5.2.3 port-for==0.6.1 pycparser==2.20 pyelftools==0.27 diff --git a/src/_C002.ino b/src/_C002.ino index 12888b832..e38bfeef5 100644 --- a/src/_C002.ino +++ b/src/_C002.ino @@ -82,7 +82,9 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String& if (deserializeDomoticzJson(event->String2, idx, nvalue, nvaluealt, svalue1, switchtype)) { for (taskIndex_t x = 0; x < TASKS_MAX; x++) { // We need the index of the controller we are: 0...CONTROLLER_MAX - if (Settings.TaskDeviceEnabled[x] && (Settings.TaskDeviceID[ControllerID][x] == idx)) // get idx for our controller index + if (Settings.TaskDeviceEnabled[x] && + Settings.TaskDeviceSendData[ControllerID][x] && + (Settings.TaskDeviceID[ControllerID][x] == idx)) // get idx for our controller index { String action; bool mustSendEvent = false; diff --git a/src/_C005.ino b/src/_C005.ino index 0f5002678..c1acdd727 100644 --- a/src/_C005.ino +++ b/src/_C005.ino @@ -81,7 +81,7 @@ bool CPlugin_005(CPlugin::Function function, struct EventStruct *event, String& const int lastindex = event->String1.lastIndexOf('/'); const String lastPartTopic = event->String1.substring(lastindex + 1); - if (lastPartTopic == F("cmd")) { + if (lastPartTopic.equals(F("cmd"))) { // Example: // topic: ESP_Easy/Bathroom_pir_env/cmd // data: gpio,14,0 @@ -116,14 +116,14 @@ bool CPlugin_005(CPlugin::Function function, struct EventStruct *event, String& if (validTopic) { // in case of event, store to buffer and return... - String command = parseString(cmd, 1); + const String command = parseString(cmd, 1); - if ((command == F("event")) || (command == F("asyncevent"))) { + if ((command.equals(F("event"))) || (command.equals(F("asyncevent")))) { if (Settings.UseRules) { eventQueue.addMove(parseStringToEnd(cmd, 2)); } } else { - ExecuteCommand(event->TaskIndex, EventValueSource::Enum::VALUE_SOURCE_MQTT, cmd.c_str(), true, true, true); + ExecuteCommand_all(EventValueSource::Enum::VALUE_SOURCE_MQTT, cmd.c_str()); } } } diff --git a/src/_C006.ino b/src/_C006.ino index cdd7fd225..f19221790 100644 --- a/src/_C006.ino +++ b/src/_C006.ino @@ -92,9 +92,10 @@ bool CPlugin_006(CPlugin::Function function, struct EventStruct *event, String& cmd += topicSplit[6].toInt(); // Par1 cmd += ','; - if ((event->String2 == F("false")) || (event->String2 == F("true"))) + if ((event->String2.equalsIgnoreCase(F("false"))) || + (event->String2.equalsIgnoreCase(F("true")))) { - cmd += (event->String2 == F("true")) ? '1' : '0'; // Par2 + cmd += (event->String2.equalsIgnoreCase(F("true"))) ? '1' : '0'; // Par2 } else {