mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
устранен баг телеграма, баг сценариев....
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
0;inoutput;tUp1;inputDigit;Термостат1;Верхний#порог;3
|
0;inoutput;tUp1;inputDigit;Термостат1;Верхний#порог;3
|
||||||
0;inoutput;tLow1;inputDigit;Термостат1;Нижний#порог;4
|
0;inoutput;tLow1;inputDigit;Термостат1;Нижний#порог;4
|
||||||
0;button-out;btn1;toggle;Термостат1;Нагрев;5;pin[12]*
|
0;button-out;btn1;toggle;Термостат1;Нагрев;5;pin[12]*
|
||||||
0;dallas-temp;t2;anydataTemp;Термостат2;Температура;1;pin[2];index[0];int[60]
|
0;dallas-temp;t2;anydataTemp;Термостат2;Температура;1;pin[2];index[0];int[10]
|
||||||
0;logging;log2;chart;Термостат2;История;2;val[t2];int[10];cnt[100]
|
0;logging;log2;chart;Термостат2;История;2;val[t2];int[10];cnt[100]
|
||||||
0;inoutput;threshold;inputDigitTemp;Термостат2;Заданная#температура;3
|
0;inoutput;threshold;inputDigitTemp;Термостат2;Заданная#температура;3
|
||||||
0;button-out;heater2;toggle;Термостат2;Нагреватель;7;pin[12]
|
0;button-out;heater2;toggle;Термостат2;Нагреватель;7;pin[5]
|
||||||
0;inoutput;time21;inputTimeClock;Расписание2;Утренний#период;8
|
0;inoutput;time21;inputTimeClock;Расписание2;Утренний#период;8
|
||||||
0;inoutput;threshold1;inputDigitTemp;Расписание2;Температура;9
|
0;inoutput;threshold1;inputDigitTemp;Расписание2;Температура;9
|
||||||
0;inoutput;time22;inputTimeClock;Расписание2;Дневной#период;10
|
0;inoutput;time22;inputTimeClock;Расписание2;Дневной#период;10
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
t1 > tUp1
|
t1 > tUp1
|
||||||
btn1 0
|
btn1 0
|
||||||
telegram нагрев#выключен 1
|
telegram Гостинная нагрев#выключен
|
||||||
end
|
end
|
||||||
t1 < tLow1
|
t1 < tLow1
|
||||||
btn1 1
|
btn1 1
|
||||||
telegram нагрев#включен 1
|
telegram Гостинная нагрев#включен
|
||||||
end*
|
end*
|
||||||
t2 > threshold+-2
|
t2 > threshold+-2
|
||||||
heater2 0
|
heater2 0
|
||||||
@@ -26,11 +26,11 @@ threshold threshold4
|
|||||||
end*
|
end*
|
||||||
h3 > hUp3
|
h3 > hUp3
|
||||||
hUp3 0
|
hUp3 0
|
||||||
telegram полив#выключен 1
|
telegram Теплица полив#выключен
|
||||||
end
|
end
|
||||||
h3 < hLow3
|
h3 < hLow3
|
||||||
hUp3 1
|
hUp3 1
|
||||||
telegram полив#включен 1
|
telegram Теплица полив#включен
|
||||||
end*
|
end*
|
||||||
timenow = time41
|
timenow = time41
|
||||||
btn41 1
|
btn41 1
|
||||||
@@ -65,7 +65,7 @@ end*
|
|||||||
sensor = 1
|
sensor = 1
|
||||||
text обнаружено
|
text обнаружено
|
||||||
time %date%
|
time %date%
|
||||||
telegram text обнаружено#движение 1
|
telegram often Обнаружено#движение
|
||||||
end
|
end
|
||||||
reset = 1
|
reset = 1
|
||||||
text не#обнаружено
|
text не#обнаружено
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "ItemsList.h"
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "ItemsList.h"
|
||||||
#include "Utils/JsonUtils.h"
|
#include "Utils/JsonUtils.h"
|
||||||
|
|
||||||
class LineParsing {
|
class LineParsing {
|
||||||
@@ -110,10 +111,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pin != "") {
|
||||||
if (!isPinExist(_pin.toInt()) || !isDigitStr(_pin)) {
|
if (!isPinExist(_pin.toInt()) || !isDigitStr(_pin)) {
|
||||||
pinErrors++;
|
pinErrors++;
|
||||||
|
Serial.println("'" + _pin + "'");
|
||||||
_pin = "";
|
_pin = "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_page.replace("#", " ");
|
_page.replace("#", " ");
|
||||||
_descr.replace("#", " ");
|
_descr.replace("#", " ");
|
||||||
@@ -123,7 +127,6 @@ public:
|
|||||||
createWidget(_descr, _page, _order, _file, _key);
|
createWidget(_descr, _page, _order, _file, _key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String gkey() {
|
String gkey() {
|
||||||
return _key;
|
return _key;
|
||||||
}
|
}
|
||||||
@@ -176,7 +179,6 @@ public:
|
|||||||
return _index;
|
return _index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int getPinErrors() {
|
int getPinErrors() {
|
||||||
return pinErrors;
|
return pinErrors;
|
||||||
}
|
}
|
||||||
@@ -185,7 +187,6 @@ public:
|
|||||||
pinErrors = 0;
|
pinErrors = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
_key = "";
|
_key = "";
|
||||||
_file = "";
|
_file = "";
|
||||||
|
|||||||
3
include/Tests.h
Normal file
3
include/Tests.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern void testsPerform();
|
||||||
@@ -106,7 +106,7 @@ void deviceInit() {
|
|||||||
|
|
||||||
int errors = myLineParsing.getPinErrors();
|
int errors = myLineParsing.getPinErrors();
|
||||||
|
|
||||||
if (errors != 0) {
|
if (errors > 0) {
|
||||||
jsonWriteStr(configSetupJson, F("warning3"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Обнаружен неверный номер пина</p></font></div>"));
|
jsonWriteStr(configSetupJson, F("warning3"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Обнаружен неверный номер пина</p></font></div>"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "ItemsList.h"
|
#include "ItemsList.h"
|
||||||
|
|
||||||
#include "FileSystem.h"
|
|
||||||
#include "Class/NotAsync.h"
|
#include "Class/NotAsync.h"
|
||||||
|
#include "FileSystem.h"
|
||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
#include "Utils/StringUtils.h"
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,6 @@ void itemsListInit() {
|
|||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
|
|
||||||
SerialPrint("I", F("Items"), F("Items Init"));
|
SerialPrint("I", F("Items"), F("Items Init"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +60,6 @@ void addItem2(String param) {
|
|||||||
Serial.println(seachingLine);
|
Serial.println(seachingLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void addPreset2(int num) {
|
void addPreset2(int num) {
|
||||||
File configFile = FileFS.open("/presets/presets.c.txt", "r");
|
File configFile = FileFS.open("/presets/presets.c.txt", "r");
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
@@ -76,8 +74,7 @@ void addPreset2(int num) {
|
|||||||
if (i1 == num) {
|
if (i1 == num) {
|
||||||
if (i1 == 1) {
|
if (i1 == 1) {
|
||||||
config = "\n" + item;
|
config = "\n" + item;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
config = item;
|
config = item;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -85,7 +82,7 @@ void addPreset2(int num) {
|
|||||||
}
|
}
|
||||||
configFile.close();
|
configFile.close();
|
||||||
addFile(DEVICE_CONFIG_FILE, config);
|
addFile(DEVICE_CONFIG_FILE, config);
|
||||||
|
//===========================================================================
|
||||||
File scenFile = FileFS.open("/presets/presets.s.txt", "r");
|
File scenFile = FileFS.open("/presets/presets.s.txt", "r");
|
||||||
if (!scenFile) {
|
if (!scenFile) {
|
||||||
return;
|
return;
|
||||||
@@ -97,17 +94,23 @@ void addPreset2(int num) {
|
|||||||
i2++;
|
i2++;
|
||||||
String item = scenFile.readStringUntil('*');
|
String item = scenFile.readStringUntil('*');
|
||||||
if (i2 == num) {
|
if (i2 == num) {
|
||||||
|
if (i1 == 1) {
|
||||||
|
scen = "\n" + item;
|
||||||
|
} else {
|
||||||
scen = item;
|
scen = item;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scenFile.close();
|
scenFile.close();
|
||||||
if (readFile(String(DEVICE_SCENARIO_FILE), 2048) == "//") {
|
if (readFile(String(DEVICE_SCENARIO_FILE), 2048) == "//") {
|
||||||
removeFile(DEVICE_SCENARIO_FILE);
|
removeFile(DEVICE_SCENARIO_FILE);
|
||||||
}
|
scen = deleteBeforeDelimiter(scen, "\n");
|
||||||
|
addFile(DEVICE_SCENARIO_FILE, scen);
|
||||||
|
} else {
|
||||||
addFile(DEVICE_SCENARIO_FILE, scen);
|
addFile(DEVICE_SCENARIO_FILE, scen);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void delAllItems() {
|
void delAllItems() {
|
||||||
removeFile(DEVICE_CONFIG_FILE);
|
removeFile(DEVICE_CONFIG_FILE);
|
||||||
@@ -138,8 +141,7 @@ uint8_t getFreePinAll() {
|
|||||||
uint8_t i = getNewElementNumber("pins.txt");
|
uint8_t i = getNewElementNumber("pins.txt");
|
||||||
if (i < array_sz) {
|
if (i < array_sz) {
|
||||||
return pins[i];
|
return pins[i];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,8 +174,7 @@ void delChoosingItems() {
|
|||||||
String item = configFile.readStringUntil('\n');
|
String item = configFile.readStringUntil('\n');
|
||||||
if (firstLine) {
|
if (firstLine) {
|
||||||
finalConf += item;
|
finalConf += item;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
int checkbox = selectToMarker(item, ";").toInt();
|
int checkbox = selectToMarker(item, ";").toInt();
|
||||||
if (checkbox == 0) {
|
if (checkbox == 0) {
|
||||||
finalConf += "\n" + item;
|
finalConf += "\n" + item;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#include "Consts.h"
|
#include "Consts.h"
|
||||||
#ifdef telegramEnable
|
#ifdef telegramEnable
|
||||||
#include "Telegram.h"
|
|
||||||
#include "BufferExecute.h"
|
#include "BufferExecute.h"
|
||||||
|
#include "Telegram.h"
|
||||||
CTBot* myBot{nullptr};
|
CTBot* myBot{nullptr};
|
||||||
|
|
||||||
void telegramInit() {
|
void telegramInit() {
|
||||||
if (isTelegramEnabled()) {
|
if (isTelegramEnabled()) {
|
||||||
telegramInitBeen = true;
|
telegramInitBeen = true;
|
||||||
sCmd.addCommand("telegramEnable", sendTelegramMsg);
|
sCmd.addCommand("telegram", sendTelegramMsg);
|
||||||
String token = jsonReadStr(configSetupJson, "telegramApi");
|
String token = jsonReadStr(configSetupJson, "telegramApi");
|
||||||
if (!myBot) {
|
if (!myBot) {
|
||||||
myBot = new CTBot();
|
myBot = new CTBot();
|
||||||
@@ -16,8 +16,7 @@ void telegramInit() {
|
|||||||
myBot->enableUTF8Encoding(true);
|
myBot->enableUTF8Encoding(true);
|
||||||
if (myBot->testConnection()) {
|
if (myBot->testConnection()) {
|
||||||
SerialPrint("I", "Telegram", "Connected");
|
SerialPrint("I", "Telegram", "Connected");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SerialPrint("E", "Telegram", "Not connected");
|
SerialPrint("E", "Telegram", "Not connected");
|
||||||
}
|
}
|
||||||
SerialPrint("I", F("Telegram"), F("Telegram Init"));
|
SerialPrint("I", F("Telegram"), F("Telegram Init"));
|
||||||
@@ -53,36 +52,34 @@ void telegramMsgParse(String msg) {
|
|||||||
loopCmdAdd(String(msg) + ",");
|
loopCmdAdd(String(msg) + ",");
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "order done");
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "order done");
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
||||||
}
|
} else if (msg.indexOf("get") != -1) {
|
||||||
else if (msg.indexOf("get") != -1) {
|
|
||||||
msg = deleteBeforeDelimiter(msg, "_");
|
msg = deleteBeforeDelimiter(msg, "_");
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), getValue(msg)); //jsonReadStr(configLiveJson , msg));
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), getValue(msg)); //jsonReadStr(configLiveJson , msg));
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
||||||
}
|
} else if (msg.indexOf("all") != -1) {
|
||||||
else if (msg.indexOf("all") != -1) {
|
|
||||||
String list = returnListOfParams();
|
String list = returnListOfParams();
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list);
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list);
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), F("Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value"));
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), F("Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendTelegramMsg() {
|
void sendTelegramMsg() {
|
||||||
String id = sCmd.next();
|
String sabject = sCmd.next();
|
||||||
String msg = sCmd.next();
|
String msg = sCmd.next();
|
||||||
|
if (sabject == "often") {
|
||||||
msg.replace("#", " ");
|
msg.replace("#", " ");
|
||||||
if (id == "often") {
|
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||||
}
|
} else {
|
||||||
else {
|
String prevMsg = jsonReadStr(telegramMsgJson, sabject);
|
||||||
String prevMsg = jsonReadStr(telegramMsgJson, id);
|
|
||||||
if (prevMsg != msg) {
|
if (prevMsg != msg) {
|
||||||
jsonWriteStr(telegramMsgJson, id, msg);
|
jsonWriteStr(telegramMsgJson, sabject, msg);
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
msg.replace("#", " ");
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
sabject.replace("#", " ");
|
||||||
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), sabject + " " + msg);
|
||||||
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + sabject + " " + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +92,6 @@ bool isTelegramInputOn() {
|
|||||||
return jsonReadBool(configSetupJson, "teleginput");
|
return jsonReadBool(configSetupJson, "teleginput");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String returnListOfParams() {
|
String returnListOfParams() {
|
||||||
String cmdStr = readFile(DEVICE_CONFIG_FILE, 4096);
|
String cmdStr = readFile(DEVICE_CONFIG_FILE, 4096);
|
||||||
cmdStr += "\r\n";
|
cmdStr += "\r\n";
|
||||||
|
|||||||
12
src/Tests.cpp
Normal file
12
src/Tests.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#include "Tests.h"
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "ItemsList.h"
|
||||||
|
|
||||||
|
void testsPerform() {
|
||||||
|
Serial.println("====some tests section====");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Serial.println("==========end============");
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "Telegram.h"
|
#include "Telegram.h"
|
||||||
#include "SoftUART.h"
|
#include "SoftUART.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
#include "Tests.h"
|
||||||
|
|
||||||
void not_async_actions();
|
void not_async_actions();
|
||||||
|
|
||||||
@@ -67,7 +68,9 @@ void setup() {
|
|||||||
SsdpInit();
|
SsdpInit();
|
||||||
#endif
|
#endif
|
||||||
getFSInfo();
|
getFSInfo();
|
||||||
//esp_log_level_set("esp_littlefs", ESP_LOG_NONE);
|
|
||||||
|
testsPerform();
|
||||||
|
|
||||||
just_load = false;
|
just_load = false;
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user