mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
fixed some bugs
This commit is contained in:
@@ -1 +1 @@
|
||||
0;button-out;id;toggleSunMoon;Кнопки;Освещение;order;st[0]
|
||||
0;button-out;id;toggle;Кнопки;Освещение;order;st[0]
|
||||
@@ -72,15 +72,18 @@ class Scenario {
|
||||
} else if (_conditionSign == "!=") {
|
||||
flag = _eventValue != _conditionValue;
|
||||
} else if (_conditionSign == "<") {
|
||||
flag = _eventValue.toInt() < _conditionValue.toInt();
|
||||
flag = _eventValue.toFloat() < _conditionValue.toFloat();
|
||||
} else if (_conditionSign == ">") {
|
||||
flag = _eventValue.toInt() > _conditionValue.toInt();
|
||||
flag = _eventValue.toFloat() > _conditionValue.toFloat();
|
||||
} else if (_conditionSign == ">=") {
|
||||
flag = _eventValue.toInt() >= _conditionValue.toInt();
|
||||
flag = _eventValue.toFloat() >= _conditionValue.toFloat();
|
||||
} else if (_conditionSign == "<=") {
|
||||
flag = _eventValue.toInt() <= _conditionValue.toInt();
|
||||
flag = _eventValue.toFloat() <= _conditionValue.toFloat();
|
||||
}
|
||||
|
||||
Serial.println("event Value: " + _eventValue);
|
||||
Serial.println("cond Value: " + _conditionValue);
|
||||
|
||||
if (flag) Serial.println("I Scenario event: " + _condition);
|
||||
|
||||
return flag;
|
||||
@@ -97,7 +100,7 @@ class Scenario {
|
||||
this->calculate2();
|
||||
if (this->isConditionSatisfied()) { //если вошедшее событие выполняет условие сценария
|
||||
_scenBlok = deleteBeforeDelimiter(_scenBlok, "\n");
|
||||
//Serial.println(" [>] Making: " + _scenBlok);
|
||||
Serial.println(" [>] Making: " + _scenBlok);
|
||||
spaceCmdExecute(_scenBlok);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
//#define MDNS_ENABLED
|
||||
//#define WEBSOCKET_ENABLED
|
||||
//#define LAYOUT_IN_RAM
|
||||
#define UDP_ENABLED
|
||||
//#define UDP_ENABLED
|
||||
//#define SSDP_ENABLED
|
||||
|
||||
//=========Sensors enable/disable=================================================================================================================================
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "Global.h"
|
||||
|
||||
class ButtonOutClass : public LineParsing {
|
||||
public:
|
||||
ButtonOutClass() : LineParsing(){};
|
||||
public:
|
||||
ButtonOutClass() : LineParsing() {};
|
||||
|
||||
void init() {
|
||||
if (_pin != "") {
|
||||
@@ -28,12 +28,13 @@ class ButtonOutClass : public LineParsing {
|
||||
|
||||
if (inv == "") {
|
||||
digitalWrite(pinInt, state.toInt());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
digitalWrite(pinInt, !state.toInt());
|
||||
}
|
||||
eventGen(key, "");
|
||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||
publishStatus(key, state);
|
||||
publishStatus(key, state);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
class SensorDallasClass : public SensorConvertingClass {
|
||||
public:
|
||||
SensorDallasClass() : SensorConvertingClass(){};
|
||||
public:
|
||||
SensorDallasClass() : SensorConvertingClass() {};
|
||||
|
||||
void SensorDallasInit() {
|
||||
oneWire = new OneWire((uint8_t)_pin.toInt());
|
||||
@@ -36,7 +36,7 @@ class SensorDallasClass : public SensorConvertingClass {
|
||||
float valueFl = this->correction(key, value);
|
||||
eventGen(key, "");
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
publishStatus(key, String(valueFl));
|
||||
publishStatus(key, String(valueFl));
|
||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||
}
|
||||
}
|
||||
|
||||
148
src/Scenario.cpp
148
src/Scenario.cpp
@@ -8,68 +8,68 @@ boolean isScenarioEnabled() {
|
||||
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
|
||||
}
|
||||
|
||||
void loopScenario() {
|
||||
if (!isScenarioEnabled()) {
|
||||
return;
|
||||
}
|
||||
String scenarioTmp = scenario;
|
||||
scenarioTmp += "\n";
|
||||
scenarioTmp.replace("\r\n", "\n");
|
||||
scenarioTmp.replace("\r", "\n");
|
||||
|
||||
while (scenarioTmp.length()) {
|
||||
String scenBlok = selectToMarker(scenarioTmp, "end"); //выделяем первый сценарий
|
||||
if (!scenBlok.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
i++;
|
||||
if (scenario_line_status[i] == 1) {
|
||||
String condition = selectToMarker(scenBlok, "\n"); //выделяем условие
|
||||
|
||||
String conditionParam = selectFromMarkerToMarker(condition, " ", 0); //выделяем параметр условия
|
||||
String order = eventBuf;
|
||||
String eventParam = selectToMarker(order, ","); //выделяем параметр события
|
||||
|
||||
if (conditionParam == eventParam) { //если поступившее событие равно событию заданному buttonSet1 в файле начинаем его обработку
|
||||
|
||||
String conditionSign = selectFromMarkerToMarker(condition, " ", 1); //выделяем знак (=)
|
||||
|
||||
String conditionValue = selectFromMarkerToMarker(condition, " ", 2); //выделяем значение (1)
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
String eventParam = jsonReadStr(configLiveJson, conditionParam); //получаем значение этого параметра события из json
|
||||
|
||||
if (conditionSign == "=") {
|
||||
flag = eventParam == conditionValue;
|
||||
} else if (conditionSign == "!=") {
|
||||
flag = eventParam != conditionValue;
|
||||
} else if (conditionSign == "<") {
|
||||
flag = eventParam.toInt() < conditionValue.toInt();
|
||||
} else if (conditionSign == ">") {
|
||||
flag = eventParam.toInt() > conditionValue.toInt();
|
||||
} else if (conditionSign == ">=") {
|
||||
flag = eventParam.toInt() >= conditionValue.toInt();
|
||||
} else if (conditionSign == "<=") {
|
||||
flag = eventParam.toInt() <= conditionValue.toInt();
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
scenBlok = deleteBeforeDelimiter(scenBlok, "\n"); // удаляем строку самого сценария оставляя только команды
|
||||
SerialPrint("I","module","do: " + scenBlok);
|
||||
spaceCmdExecute(scenBlok); // выполняем все команды
|
||||
}
|
||||
}
|
||||
}
|
||||
scenarioTmp = deleteBeforeDelimiter(scenarioTmp, "end\n"); //удаляем первый сценарий
|
||||
}
|
||||
|
||||
String eventBufTmp = eventBuf; //читаем файл событий
|
||||
eventBufTmp = deleteBeforeDelimiter(eventBufTmp, ","); //удаляем выполненное событие
|
||||
eventBuf = eventBufTmp; //записываем обновленный файл событий
|
||||
}
|
||||
//void loopScenario() {
|
||||
// if (!isScenarioEnabled()) {
|
||||
// return;
|
||||
// }
|
||||
// String scenarioTmp = scenario;
|
||||
// scenarioTmp += "\n";
|
||||
// scenarioTmp.replace("\r\n", "\n");
|
||||
// scenarioTmp.replace("\r", "\n");
|
||||
//
|
||||
// while (scenarioTmp.length()) {
|
||||
// String scenBlok = selectToMarker(scenarioTmp, "end"); //выделяем первый сценарий
|
||||
// if (!scenBlok.length()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// size_t i = 0;
|
||||
// i++;
|
||||
// if (scenario_line_status[i] == 1) {
|
||||
// String condition = selectToMarker(scenBlok, "\n"); //выделяем условие
|
||||
//
|
||||
// String conditionParam = selectFromMarkerToMarker(condition, " ", 0); //выделяем параметр условия
|
||||
// String order = eventBuf;
|
||||
// String eventParam = selectToMarker(order, ","); //выделяем параметр события
|
||||
//
|
||||
// if (conditionParam == eventParam) { //если поступившее событие равно событию заданному buttonSet1 в файле начинаем его обработку
|
||||
//
|
||||
// String conditionSign = selectFromMarkerToMarker(condition, " ", 1); //выделяем знак (=)
|
||||
//
|
||||
// String conditionValue = selectFromMarkerToMarker(condition, " ", 2); //выделяем значение (1)
|
||||
//
|
||||
// boolean flag = false;
|
||||
//
|
||||
// String eventParam = jsonReadStr(configLiveJson, conditionParam); //получаем значение этого параметра события из json
|
||||
//
|
||||
// if (conditionSign == "=") {
|
||||
// flag = eventParam == conditionValue;
|
||||
// } else if (conditionSign == "!=") {
|
||||
// flag = eventParam != conditionValue;
|
||||
// } else if (conditionSign == "<") {
|
||||
// flag = eventParam.toInt() < conditionValue.toInt();
|
||||
// } else if (conditionSign == ">") {
|
||||
// flag = eventParam.toInt() > conditionValue.toInt();
|
||||
// } else if (conditionSign == ">=") {
|
||||
// flag = eventParam.toInt() >= conditionValue.toInt();
|
||||
// } else if (conditionSign == "<=") {
|
||||
// flag = eventParam.toInt() <= conditionValue.toInt();
|
||||
// }
|
||||
//
|
||||
// if (flag) {
|
||||
// scenBlok = deleteBeforeDelimiter(scenBlok, "\n"); // удаляем строку самого сценария оставляя только команды
|
||||
// SerialPrint("I","module","do: " + scenBlok);
|
||||
// spaceCmdExecute(scenBlok); // выполняем все команды
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// scenarioTmp = deleteBeforeDelimiter(scenarioTmp, "end\n"); //удаляем первый сценарий
|
||||
// }
|
||||
//
|
||||
// String eventBufTmp = eventBuf; //читаем файл событий
|
||||
// eventBufTmp = deleteBeforeDelimiter(eventBufTmp, ","); //удаляем выполненное событие
|
||||
// eventBuf = eventBufTmp; //записываем обновленный файл событий
|
||||
//}
|
||||
|
||||
void eventGen(String event_name, String number) {
|
||||
if (!jsonReadBool(configSetupJson, "scen")) {
|
||||
@@ -78,18 +78,18 @@ void eventGen(String event_name, String number) {
|
||||
eventBuf = event_name + number + ",";
|
||||
}
|
||||
|
||||
String add_set(String str) {
|
||||
String num1 = str.substring(str.length() - 1);
|
||||
String num2 = str.substring(str.length() - 2, str.length() - 1);
|
||||
if (isDigitStr(num1) && isDigitStr(num2)) {
|
||||
str = str.substring(0, str.length() - 2) + "Set" + num2 + num1;
|
||||
} else {
|
||||
if (isDigitStr(num1)) {
|
||||
str = str.substring(0, str.length() - 1) + "Set" + num1;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
//String add_set(String str) {
|
||||
// String num1 = str.substring(str.length() - 1);
|
||||
// String num2 = str.substring(str.length() - 2, str.length() - 1);
|
||||
// if (isDigitStr(num1) && isDigitStr(num2)) {
|
||||
// str = str.substring(0, str.length() - 2) + "Set" + num2 + num1;
|
||||
// } else {
|
||||
// if (isDigitStr(num1)) {
|
||||
// str = str.substring(0, str.length() - 1) + "Set" + num1;
|
||||
// }
|
||||
// }
|
||||
// return str;
|
||||
//}
|
||||
|
||||
//button-out1 = 1
|
||||
//button-out2 1
|
||||
|
||||
Reference in New Issue
Block a user