mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
@@ -5,15 +5,15 @@
|
|||||||
"appass": "",
|
"appass": "",
|
||||||
"routerssid": "VOLODYA",
|
"routerssid": "VOLODYA",
|
||||||
"routerpass": "BELCHENKO",
|
"routerpass": "BELCHENKO",
|
||||||
"timezone": 2,
|
"timezone": 1,
|
||||||
"ntp": "pool.ntp.org",
|
"ntp": "pool.ntp.org",
|
||||||
"mqttServer": "91.204.228.124",
|
"mqttServer": "m12.cloudmqtt.com",
|
||||||
"mqttPort": 1883,
|
"mqttPort": 14053,
|
||||||
"mqttPrefix": "/iotTest",
|
"mqttPrefix": "/iotTest",
|
||||||
"mqttUser": "rise",
|
"mqttUser": "lbscvzuj",
|
||||||
"mqttPass": "23ri22se32",
|
"mqttPass": "bLxlveOgaF8F",
|
||||||
"scen": "1",
|
"scen": "1",
|
||||||
"telegramApi": "1425283609:AAFf3YO8ouCJF23kU8CMiU7XXy21MFhbn9w",
|
"telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
|
||||||
"telegonof": "0",
|
"telegonof": "0",
|
||||||
"weblogin": "admin",
|
"weblogin": "admin",
|
||||||
"webpass": "admin",
|
"webpass": "admin",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0;input-time;id;inputTime;Ввод;Введите#время;order;st[10:00:00]
|
0;input-time;id;inputTime;Ввод;Введите#время;order;st[10:00]
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
temp > inputU
|
temp > inputU
|
||||||
button 0
|
button 0
|
||||||
|
telegram нагрев#выключен 1
|
||||||
end
|
end
|
||||||
temp < inputL
|
temp < inputL
|
||||||
button 1
|
button 1
|
||||||
|
telegram нагрев#включен 1
|
||||||
end
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1]
|
0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1]
|
||||||
0;logging;log;chart;Теплица;Влажность;2;val[hum];int[60];cnt[100]
|
0;logging;log;chart;Теплица;История;2;val[hum];int[60];cnt[100]
|
||||||
0;input-digit;inputU;inputDigit;Теплица;Верхний#порог;3;st[45]
|
0;input-digit;inputU;inputDigit;Теплица;Верхний#порог;3;st[45]
|
||||||
0;input-digit;inputL;inputDigit;Теплица;Нижний#порог;4;st[35]
|
0;input-digit;inputL;inputDigit;Теплица;Нижний#порог;4;st[35]
|
||||||
0;button-out;button;toggle;Теплица;Полив;5;pin[12];st[0]
|
0;button-out;button;toggle;Теплица;Полив;5;pin[12];st[0]
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
hum > inputU
|
hum > inputU
|
||||||
button 0
|
button 0
|
||||||
|
telegram полив#выключен 1
|
||||||
end
|
end
|
||||||
hum < inputL
|
hum < inputL
|
||||||
button 1
|
button 1
|
||||||
|
telegram полив#включен 1
|
||||||
end
|
end
|
||||||
4
data/presets/rel.c.txt
Normal file
4
data/presets/rel.c.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0;button-out;button1;toggle;Реле;Освещение;1;pin[12];st[0]
|
||||||
|
0;button-out;button2;toggle;Реле;Освещение;2;pin[13];st[0]
|
||||||
|
0;input-time;T1;inputTime;Реле;Введите#время#включения;3;st[10:00]
|
||||||
|
0;input-time;T2;inputTime;Реле;Введите#время#выключения;4;st[11:00]
|
||||||
8
data/presets/rel.s.txt
Normal file
8
data/presets/rel.s.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
timenow = T1
|
||||||
|
button1 1
|
||||||
|
button2 0
|
||||||
|
end
|
||||||
|
timenow = T2
|
||||||
|
button1 0
|
||||||
|
button2 1
|
||||||
|
end
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "LittleFS version: 266"
|
"title": "LittleFS version: 267"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
@@ -87,8 +87,9 @@
|
|||||||
"style": "display:inline",
|
"style": "display:inline",
|
||||||
"title": {
|
"title": {
|
||||||
"#": "Выберите пресет из списка<span class=\"caret\"></span>",
|
"#": "Выберите пресет из списка<span class=\"caret\"></span>",
|
||||||
"/set?addPreset=dal.c": "1.Термостат на основе ds18b20 (устройство держит заданный уровень температуры)",
|
"/set?addPreset=dal.c": "1.Термостат на основе ds18b20 с оповещением в телеграм",
|
||||||
"/set?addPreset=dht.c": "2.Контроль влажности на основе DHT (устройство держит заданный уровень влажности)"
|
"/set?addPreset=dht.c": "2.Контроль влажности на основе DHT с оповещением в телеграм",
|
||||||
|
"/set?addPreset=rel.c": "3.Включение выключение реле в заданное время"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -184,6 +185,15 @@
|
|||||||
"action": "/check",
|
"action": "/check",
|
||||||
"response": "[[my-block]]",
|
"response": "[[my-block]]",
|
||||||
"class": "btn btn-block btn-default"
|
"class": "btn btn-block btn-default"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "link",
|
||||||
|
"title": "Перезагрузить устройство",
|
||||||
|
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/set?device=ok');}",
|
||||||
|
"class": "btn btn-block btn-danger"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,15 @@
|
|||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"title": "<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #F5F5F5; padding: 10px;'>После настройки telegram перезагрузите устройство что бы изменения вступили в силу</p></font></div>"
|
"title": "<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #F5F5F5; padding: 10px;'>После настройки telegram перезагрузите устройство что бы изменения вступили в силу</p></font></div>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "link",
|
||||||
|
"title": "Перезагрузить устройство",
|
||||||
|
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/set?device=ok');}",
|
||||||
|
"class": "btn btn-block btn-danger"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include "Cmd.h"
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
class Scenario {
|
|
||||||
protected:
|
|
||||||
String _scenarioTmp;
|
|
||||||
String _condition;
|
|
||||||
String _conditionParam;
|
|
||||||
String _conditionSign;
|
|
||||||
String _conditionValue;
|
|
||||||
String _scenBlok;
|
|
||||||
String _event;
|
|
||||||
String _eventParam;
|
|
||||||
String _eventValue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Scenario() : _scenarioTmp{ "" },
|
|
||||||
_condition{ "" },
|
|
||||||
_conditionParam{ "" },
|
|
||||||
_conditionSign{ "" },
|
|
||||||
_conditionValue{ "" },
|
|
||||||
_scenBlok{ "" },
|
|
||||||
_event{ "" },
|
|
||||||
_eventParam{ "" },
|
|
||||||
_eventValue{ "" } {};
|
|
||||||
|
|
||||||
void load() {
|
|
||||||
_scenarioTmp = scenario;
|
|
||||||
}
|
|
||||||
|
|
||||||
void calculate1() {
|
|
||||||
_scenBlok = selectToMarker(_scenarioTmp, "end\n");
|
|
||||||
_condition = selectToMarker(_scenBlok, "\n");
|
|
||||||
_eventParam = selectToMarker(eventBuf, ",");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isIncommingEventInScenario() {
|
|
||||||
bool ret = false;
|
|
||||||
if (_condition.indexOf(_eventParam) != -1) {
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void calculate2() {
|
|
||||||
_scenarioTmp += "\n";
|
|
||||||
_scenarioTmp.replace("\r\n", "\n");
|
|
||||||
_scenarioTmp.replace("\r", "\n");
|
|
||||||
|
|
||||||
_conditionParam = selectFromMarkerToMarker(_condition, " ", 0);
|
|
||||||
_conditionSign = selectFromMarkerToMarker(_condition, " ", 1);
|
|
||||||
_conditionValue = selectFromMarkerToMarker(_condition, " ", 2);
|
|
||||||
if (!isDigitStr(_conditionValue)) _conditionValue = jsonReadStr(configLiveJson, _conditionValue);
|
|
||||||
_eventValue = jsonReadStr(configLiveJson, _conditionParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
void delOneScenBlock() {
|
|
||||||
_scenarioTmp = deleteBeforeDelimiter(_scenarioTmp, "end\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void delOneEvent() {
|
|
||||||
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isConditionSatisfied() {
|
|
||||||
boolean flag = false;
|
|
||||||
|
|
||||||
if (_conditionSign == "=") {
|
|
||||||
flag = _eventValue == _conditionValue;
|
|
||||||
}
|
|
||||||
else if (_conditionSign == "!=") {
|
|
||||||
flag = _eventValue != _conditionValue;
|
|
||||||
}
|
|
||||||
else if (_conditionSign == "<") {
|
|
||||||
flag = _eventValue.toFloat() < _conditionValue.toFloat();
|
|
||||||
}
|
|
||||||
else if (_conditionSign == ">") {
|
|
||||||
flag = _eventValue.toFloat() > _conditionValue.toFloat();
|
|
||||||
}
|
|
||||||
else if (_conditionSign == ">=") {
|
|
||||||
flag = _eventValue.toFloat() >= _conditionValue.toFloat();
|
|
||||||
}
|
|
||||||
else if (_conditionSign == "<=") {
|
|
||||||
flag = _eventValue.toFloat() <= _conditionValue.toFloat();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag) {
|
|
||||||
//SerialPrint("I", "Scenario", "event value: " + _eventValue);
|
|
||||||
//SerialPrint("I", "Scenario", "condition value: " + _conditionValue);
|
|
||||||
SerialPrint("I", "Scenario", "event: " + _condition);
|
|
||||||
}
|
|
||||||
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
if (!this->isScenarioEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->load(); //после этого мы получили все сценарии
|
|
||||||
while (_scenarioTmp.length() > 1) {
|
|
||||||
this->calculate1(); //расчет необходимый для ответа на следующий вопрос
|
|
||||||
if (this->isIncommingEventInScenario()) { //если вошедшее событие есть в сценарии
|
|
||||||
this->calculate2();
|
|
||||||
if (this->isConditionSatisfied()) { //если вошедшее событие выполняет условие сценария
|
|
||||||
_scenBlok = deleteBeforeDelimiter(_scenBlok, "\n");
|
|
||||||
String forPrint = _scenBlok;
|
|
||||||
forPrint.replace("end", "");
|
|
||||||
forPrint.replace("\r\n", "");
|
|
||||||
forPrint.replace("\r", "");
|
|
||||||
forPrint.replace("\n", "");
|
|
||||||
SerialPrint("I", "Scenario", "making: " + forPrint);
|
|
||||||
spaceCmdExecute(_scenBlok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->delOneScenBlock(); //удалим использованный блок
|
|
||||||
}
|
|
||||||
this->delOneEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isScenarioEnabled() {
|
|
||||||
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
extern Scenario* myScenario;
|
|
||||||
69
include/Class/ScenarioClass2.h
Normal file
69
include/Class/ScenarioClass2.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "Cmd.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class Scenario {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
String allBlocks = scenario;
|
||||||
|
allBlocks.replace("\r\n", "\n");
|
||||||
|
allBlocks.replace("\r", "\n");
|
||||||
|
allBlocks += "\n";
|
||||||
|
|
||||||
|
String incommingEvent = selectToMarker(eventBuf, ",");
|
||||||
|
|
||||||
|
while (allBlocks.length() > 1) {
|
||||||
|
String oneBlock = selectToMarker(allBlocks, "end\n");
|
||||||
|
String condition = selectToMarker(oneBlock, "\n");
|
||||||
|
|
||||||
|
String setEvent = selectFromMarkerToMarker(condition, " ", 0);
|
||||||
|
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
|
||||||
|
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
|
||||||
|
if (!isDigitStr(setEventValue)) setEventValue = jsonReadStr(configLiveJson, setEventValue);
|
||||||
|
|
||||||
|
String incommingEventValue = jsonReadStr(configLiveJson, incommingEvent);
|
||||||
|
|
||||||
|
if (incommingEvent == setEvent) {
|
||||||
|
|
||||||
|
boolean flag = false;
|
||||||
|
|
||||||
|
if (setEventSign == "=") {
|
||||||
|
flag = incommingEventValue == setEventValue;
|
||||||
|
}
|
||||||
|
else if (setEventSign == "!=") {
|
||||||
|
flag = incommingEventValue != setEventValue;
|
||||||
|
}
|
||||||
|
else if (setEventSign == "<") {
|
||||||
|
flag = incommingEventValue.toFloat() < setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
else if (setEventSign == ">") {
|
||||||
|
flag = incommingEventValue.toFloat() > setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
else if (setEventSign == ">=") {
|
||||||
|
flag = incommingEventValue.toFloat() >= setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
else if (setEventSign == "<=") {
|
||||||
|
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
//SerialPrint("I", "Scenario", "incomming Event Value: " + incommingEventValue);
|
||||||
|
//SerialPrint("I", "Scenario", "set Event Value: " + setEventValue);
|
||||||
|
|
||||||
|
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
|
||||||
|
oneBlock.replace("end", "");
|
||||||
|
SerialPrint("I", "Scenario", condition + " set:\n" + oneBlock);
|
||||||
|
spaceCmdExecute(oneBlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allBlocks = deleteBeforeDelimiter(allBlocks, "end\n");
|
||||||
|
}
|
||||||
|
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Scenario* myScenario;
|
||||||
70
include/Class/ScenarioClass3.h
Normal file
70
include/Class/ScenarioClass3.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "Cmd.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class Scenario {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
String allBlocks = scenario;
|
||||||
|
allBlocks.replace("\r\n", "\n");
|
||||||
|
allBlocks.replace("\r", "\n");
|
||||||
|
allBlocks += "\n";
|
||||||
|
|
||||||
|
String incommingEvent = selectToMarker(eventBuf, ",");
|
||||||
|
String incommingEventKey = selectToMarker(incommingEvent, " ");
|
||||||
|
String incommingEventValue = selectToMarkerLast(incommingEvent, " ");
|
||||||
|
|
||||||
|
while (allBlocks.length() > 1) {
|
||||||
|
String oneBlock = selectToMarker(allBlocks, "end\n");
|
||||||
|
String condition = selectToMarker(oneBlock, "\n");
|
||||||
|
|
||||||
|
String setEventKey = selectFromMarkerToMarker(condition, " ", 0);
|
||||||
|
|
||||||
|
if (incommingEventKey == setEventKey) {
|
||||||
|
|
||||||
|
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
|
||||||
|
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
|
||||||
|
if (!isDigitStr(setEventValue)) setEventValue = jsonReadStr(configLiveJson, setEventValue);
|
||||||
|
|
||||||
|
boolean flag = false;
|
||||||
|
|
||||||
|
if (setEventSign == "=") {
|
||||||
|
flag = incommingEventValue == setEventValue;
|
||||||
|
}
|
||||||
|
else if (setEventSign == "!=") {
|
||||||
|
flag = incommingEventValue != setEventValue;
|
||||||
|
}
|
||||||
|
else if (setEventSign == "<") {
|
||||||
|
flag = incommingEventValue.toFloat() < setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
else if (setEventSign == ">") {
|
||||||
|
flag = incommingEventValue.toFloat() > setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
else if (setEventSign == ">=") {
|
||||||
|
flag = incommingEventValue.toFloat() >= setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
else if (setEventSign == "<=") {
|
||||||
|
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
//SerialPrint("I", "Scenario", "incomming Event Value: " + incommingEventValue);
|
||||||
|
//SerialPrint("I", "Scenario", "set Event Value: " + setEventValue);
|
||||||
|
|
||||||
|
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
|
||||||
|
oneBlock.replace("end", "");
|
||||||
|
SerialPrint("I", "Scenario", condition + " \n" + oneBlock);
|
||||||
|
spaceCmdExecute(oneBlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allBlocks = deleteBeforeDelimiter(allBlocks, "end\n");
|
||||||
|
}
|
||||||
|
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Scenario* myScenario;
|
||||||
@@ -3,11 +3,11 @@
|
|||||||
//===========Firmware=============================================================================================================================================
|
//===========Firmware=============================================================================================================================================
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#define FIRMWARE_NAME "esp8266-iotm"
|
#define FIRMWARE_NAME "esp8266-iotm"
|
||||||
#define FIRMWARE_VERSION 266
|
#define FIRMWARE_VERSION 267
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#define FIRMWARE_NAME "esp32-iotm"
|
#define FIRMWARE_NAME "esp32-iotm"
|
||||||
#define FIRMWARE_VERSION 266
|
#define FIRMWARE_VERSION 267
|
||||||
#endif
|
#endif
|
||||||
#define FLASH_4MB true
|
#define FLASH_4MB true
|
||||||
|
|
||||||
@@ -106,3 +106,7 @@ enum ConfigType_t {
|
|||||||
CT_CONFIG,
|
CT_CONFIG,
|
||||||
CT_SCENARIO
|
CT_SCENARIO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//07.11.2020
|
||||||
|
//RAM: [===== ] 46.8% (used 38376 bytes from 81920 bytes)
|
||||||
|
//Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes)
|
||||||
@@ -93,7 +93,7 @@ extern void servo_();
|
|||||||
extern void setLedStatus(LedStatus_t);
|
extern void setLedStatus(LedStatus_t);
|
||||||
|
|
||||||
//Scenario
|
//Scenario
|
||||||
extern void eventGen(String event_name, String number);
|
extern void eventGen2(String eventName, String eventValue);
|
||||||
extern String add_set(String param_name);
|
extern String add_set(String param_name);
|
||||||
|
|
||||||
//Timers
|
//Timers
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ extern void telegramInit();
|
|||||||
extern void handleTelegram();
|
extern void handleTelegram();
|
||||||
extern bool isTelegramEnabled();
|
extern bool isTelegramEnabled();
|
||||||
extern void telegramMsgParse(String msg);
|
extern void telegramMsgParse(String msg);
|
||||||
|
extern String returnListOfParams();
|
||||||
@@ -52,7 +52,7 @@ class ButtonInClass : public LineParsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void switchChangeVirtual(String key, String state) {
|
void switchChangeVirtual(String key, String state) {
|
||||||
eventGen(key, "");
|
eventGen2(key, state);
|
||||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||||
publishStatus(key, state);
|
publishStatus(key, state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
else {
|
else {
|
||||||
digitalWrite(pinInt, !state.toInt());
|
digitalWrite(pinInt, !state.toInt());
|
||||||
}
|
}
|
||||||
eventGen(key, "");
|
eventGen2(key, state);
|
||||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||||
publishStatus(key, state);
|
publishStatus(key, state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ class InputClass : public LineParsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void inputSetFloat(String key, String state) {
|
void inputSetFloat(String key, String state) {
|
||||||
eventGen(key, "");
|
eventGen2(key, state);
|
||||||
jsonWriteFloat(configLiveJson, key, state.toFloat());
|
jsonWriteFloat(configLiveJson, key, state.toFloat());
|
||||||
publishStatus(key, state);
|
publishStatus(key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputSetStr(String key, String state) {
|
void inputSetStr(String key, String state) {
|
||||||
eventGen(key, "");
|
eventGen2(key, state);
|
||||||
jsonWriteStr(configLiveJson, key, state);
|
jsonWriteStr(configLiveJson, key, state);
|
||||||
publishStatus(key, state);
|
publishStatus(key, state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class OutputTextClass : public LineParsing {
|
|||||||
|
|
||||||
void OutputModuleChange(String key, String state) {
|
void OutputModuleChange(String key, String state) {
|
||||||
state.replace("#", " ");
|
state.replace("#", " ");
|
||||||
eventGen(key, "");
|
eventGen2(key, state);
|
||||||
jsonWriteStr(configLiveJson, key, state);
|
jsonWriteStr(configLiveJson, key, state);
|
||||||
publishStatus(key, state);
|
publishStatus(key, state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class PwmOutClass : public LineParsing {
|
|||||||
void pwmChange(String key, String pin, String state) {
|
void pwmChange(String key, String pin, String state) {
|
||||||
int pinInt = pin.toInt();
|
int pinInt = pin.toInt();
|
||||||
analogWrite(pinInt, state.toInt());
|
analogWrite(pinInt, state.toInt());
|
||||||
eventGen(key, "");
|
eventGen2(key, state);
|
||||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||||
publishStatus(key, state);
|
publishStatus(key, state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class SensorAnalogClass : public SensorConvertingClass {
|
|||||||
#endif
|
#endif
|
||||||
value = this->mapping(key, value);
|
value = this->mapping(key, value);
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class SensorBme280Class : public SensorConvertingClass {
|
|||||||
float value;
|
float value;
|
||||||
value = bme.readTemperature();
|
value = bme.readTemperature();
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
@@ -35,7 +35,7 @@ class SensorBme280Class : public SensorConvertingClass {
|
|||||||
float value;
|
float value;
|
||||||
value = bme.readHumidity();
|
value = bme.readHumidity();
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
@@ -46,7 +46,7 @@ class SensorBme280Class : public SensorConvertingClass {
|
|||||||
value = bme.readPressure();
|
value = bme.readPressure();
|
||||||
value = value / 1.333224 / 100;
|
value = value / 1.333224 / 100;
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class SensorBmp280Class : public SensorConvertingClass {
|
|||||||
bmp_temp->getEvent(&temp_event);
|
bmp_temp->getEvent(&temp_event);
|
||||||
value = temp_event.temperature;
|
value = temp_event.temperature;
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
@@ -39,7 +39,7 @@ class SensorBmp280Class : public SensorConvertingClass {
|
|||||||
value = pressure_event.pressure;
|
value = pressure_event.pressure;
|
||||||
value = value / 1.333224;
|
value = value / 1.333224;
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SensorDhtClass : public SensorConvertingClass {
|
|||||||
if (String(value) != "nan") {
|
if (String(value) != "nan") {
|
||||||
//value = this->mapping(key, value);
|
//value = this->mapping(key, value);
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
@@ -65,7 +65,7 @@ class SensorDhtClass : public SensorConvertingClass {
|
|||||||
if (String(value) != "nan") {
|
if (String(value) != "nan") {
|
||||||
//value = this->mapping(key, value);
|
//value = this->mapping(key, value);
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// int valueFl = this->correction(key, value);
|
// int valueFl = this->correction(key, value);
|
||||||
// eventGen(key, "");
|
// eventGen2(key, String(valueFl));
|
||||||
// jsonWriteStr(configLiveJson, key, String(valueFl));
|
// jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
// publishStatus(key, String(valueFl));
|
// publishStatus(key, String(valueFl));
|
||||||
// SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl) + ", Slave dev addr: " + String(slaveAddress) + ", Register: " + String(regAddress));
|
// SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl) + ", Slave dev addr: " + String(slaveAddress) + ", Register: " + String(regAddress));
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class SensorUltrasonic : public SensorConvertingClass {
|
|||||||
|
|
||||||
value = this->mapping(key, value);
|
value = this->mapping(key, value);
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
eventGen(key, "");
|
eventGen2(key, String(valueFl));
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
publishStatus(key, String(valueFl));
|
publishStatus(key, String(valueFl));
|
||||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
#include "Class/ScenarioClass.h"
|
|
||||||
Scenario* myScenario;
|
|
||||||
|
|
||||||
void eventGen(String event_name, String number) {
|
|
||||||
if (!jsonReadBool(configSetupJson, "scen")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
eventBuf += event_name + number + ",";
|
|
||||||
}
|
|
||||||
18
src/Class/ScenarioClass3.cpp
Normal file
18
src/Class/ScenarioClass3.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "Class/ScenarioClass3.h"
|
||||||
|
Scenario* myScenario;
|
||||||
|
|
||||||
|
//void eventGen(String event_name, String number) {
|
||||||
|
// if (!jsonReadBool(configSetupJson, "scen")) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// SerialPrint("", "", event_name);
|
||||||
|
// eventBuf += event_name + number + ",";
|
||||||
|
//}
|
||||||
|
|
||||||
|
void eventGen2(String eventName, String eventValue) {
|
||||||
|
if (!jsonReadBool(configSetupJson, "scen")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Serial.println(eventName + " " + eventValue);
|
||||||
|
eventBuf += eventName + " " + eventValue + ",";
|
||||||
|
}
|
||||||
@@ -249,7 +249,7 @@
|
|||||||
// servo->write(value);
|
// servo->write(value);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// eventGen("servo", number);
|
// eventGen2("servo", number);
|
||||||
// jsonWriteInt(configLiveJson, "servo" + number, value);
|
// jsonWriteInt(configLiveJson, "servo" + number, value);
|
||||||
// publishStatus("servo" + number, String(value, DEC));
|
// publishStatus("servo" + number, String(value, DEC));
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
// counter = 0;
|
// counter = 0;
|
||||||
// value = dht.getTemperature();
|
// value = dht.getTemperature();
|
||||||
// if (String(value) != "nan") {
|
// if (String(value) != "nan") {
|
||||||
// //eventGen(dhtT_value_name, "");
|
// //eventGen2(dhtT_value_name, "");
|
||||||
// //jsonWriteStr(configLiveJson, dhtT_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, dhtT_value_name, String(value));
|
||||||
// // publishStatus(dhtT_value_name, String(value));
|
// // publishStatus(dhtT_value_name, String(value));
|
||||||
// //SerialPrint("I", "Sensor", "'" + dhtT_value_name + "' data: " + String(value));
|
// //SerialPrint("I", "Sensor", "'" + dhtT_value_name + "' data: " + String(value));
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
// counter = 0;
|
// counter = 0;
|
||||||
// value = dht.getHumidity();
|
// value = dht.getHumidity();
|
||||||
// if (String(value) != "nan") {
|
// if (String(value) != "nan") {
|
||||||
// //eventGen(dhtH_value_name, "");
|
// //eventGen2(dhtH_value_name, "");
|
||||||
// //jsonWriteStr(configLiveJson, dhtH_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, dhtH_value_name, String(value));
|
||||||
// // publishStatus(dhtH_value_name, String(value));
|
// // publishStatus(dhtH_value_name, String(value));
|
||||||
// //SerialPrint("I", "Sensor", "'" + dhtH_value_name + "' data: " + String(value));
|
// //SerialPrint("I", "Sensor", "'" + dhtH_value_name + "' data: " + String(value));
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
// //value = dht.computePerception(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
// //value = dht.computePerception(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
||||||
// String final_line = perceptionStr(value);
|
// String final_line = perceptionStr(value);
|
||||||
// jsonWriteStr(configLiveJson, "dhtPerception", final_line);
|
// jsonWriteStr(configLiveJson, "dhtPerception", final_line);
|
||||||
// eventGen("dhtPerception", "");
|
// eventGen2("dhtPerception", "");
|
||||||
// publishStatus("dhtPerception", final_line);
|
// publishStatus("dhtPerception", final_line);
|
||||||
// if (mqtt.connected()) {
|
// if (mqtt.connected()) {
|
||||||
// SerialPrint("I", "Sensor", "'dhtPerception' data: " + final_line);
|
// SerialPrint("I", "Sensor", "'dhtPerception' data: " + final_line);
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
// //dht.getComfortRatio(cf, jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
// //dht.getComfortRatio(cf, jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
||||||
// String final_line = comfortStr(cf);
|
// String final_line = comfortStr(cf);
|
||||||
// jsonWriteStr(configLiveJson, "dhtComfort", final_line);
|
// jsonWriteStr(configLiveJson, "dhtComfort", final_line);
|
||||||
// eventGen("dhtComfort", "");
|
// eventGen2("dhtComfort", "");
|
||||||
// publishStatus("dhtComfort", final_line);
|
// publishStatus("dhtComfort", final_line);
|
||||||
// SerialPrint("I", "Sensor", "'dhtComfort' send date " + final_line);
|
// SerialPrint("I", "Sensor", "'dhtComfort' send date " + final_line);
|
||||||
// }
|
// }
|
||||||
@@ -234,7 +234,7 @@
|
|||||||
// } else {
|
// } else {
|
||||||
// //value = dht.computeDewPoint(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
// //value = dht.computeDewPoint(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
||||||
// jsonWriteInt(configLiveJson, "dhtDewpoint", value);
|
// jsonWriteInt(configLiveJson, "dhtDewpoint", value);
|
||||||
// eventGen("dhtDewpoint", "");
|
// eventGen2("dhtDewpoint", "");
|
||||||
// publishStatus("dhtDewpoint", String(value));
|
// publishStatus("dhtDewpoint", String(value));
|
||||||
// SerialPrint("I", "Sensor", "'dhtDewpoint' data: " + String(value));
|
// SerialPrint("I", "Sensor", "'dhtDewpoint' data: " + String(value));
|
||||||
// }
|
// }
|
||||||
@@ -270,7 +270,7 @@
|
|||||||
// bmp_temp->getEvent(&temp_event);
|
// bmp_temp->getEvent(&temp_event);
|
||||||
// value = temp_event.temperature;
|
// value = temp_event.temperature;
|
||||||
// //jsonWriteStr(configLiveJson, bmp280T_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bmp280T_value_name, String(value));
|
||||||
// //eventGen(bmp280T_value_name, "");
|
// //eventGen2(bmp280T_value_name, "");
|
||||||
// // publishStatus(bmp280T_value_name, String(value));
|
// // publishStatus(bmp280T_value_name, String(value));
|
||||||
// //SerialPrint("I", "Sensor", "'" + bmp280T_value_name + "' data: " + String(value));
|
// //SerialPrint("I", "Sensor", "'" + bmp280T_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
@@ -302,7 +302,7 @@
|
|||||||
// value = pressure_event.pressure;
|
// value = pressure_event.pressure;
|
||||||
// value = value / 1.333224;
|
// value = value / 1.333224;
|
||||||
// //jsonWriteStr(configLiveJson, bmp280P_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bmp280P_value_name, String(value));
|
||||||
// //eventGen(bmp280P_value_name, "");
|
// //eventGen2(bmp280P_value_name, "");
|
||||||
// // publishStatus(bmp280P_value_name, String(value));
|
// // publishStatus(bmp280P_value_name, String(value));
|
||||||
// //SerialPrint("I", "Sensor", "'" + bmp280P_value_name + "' data: " + String(value));
|
// //SerialPrint("I", "Sensor", "'" + bmp280P_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
@@ -327,7 +327,7 @@
|
|||||||
// float value = 0;
|
// float value = 0;
|
||||||
// value = bme.readTemperature();
|
// value = bme.readTemperature();
|
||||||
// //jsonWriteStr(configLiveJson, bme280T_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bme280T_value_name, String(value));
|
||||||
// //eventGen(bme280T_value_name, "");
|
// //eventGen2(bme280T_value_name, "");
|
||||||
// // publishStatus(bme280T_value_name, String(value));
|
// // publishStatus(bme280T_value_name, String(value));
|
||||||
// //SerialPrint("I", "Sensor", "'" + bme280T_value_name + "' data: " + String(value));
|
// //SerialPrint("I", "Sensor", "'" + bme280T_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
@@ -351,7 +351,7 @@
|
|||||||
// value = bme.readPressure();
|
// value = bme.readPressure();
|
||||||
// value = value / 1.333224 / 100;
|
// value = value / 1.333224 / 100;
|
||||||
// //jsonWriteStr(configLiveJson, bme280P_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bme280P_value_name, String(value));
|
||||||
// //eventGen(bme280P_value_name, "");
|
// //eventGen2(bme280P_value_name, "");
|
||||||
// // publishStatus(bme280P_value_name, String(value));
|
// // publishStatus(bme280P_value_name, String(value));
|
||||||
// //SerialPrint("I", "Sensor", "'" + bme280P_value_name + "' data: " + String(value));
|
// //SerialPrint("I", "Sensor", "'" + bme280P_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
@@ -374,7 +374,7 @@
|
|||||||
// float value = 0;
|
// float value = 0;
|
||||||
// value = bme.readHumidity();
|
// value = bme.readHumidity();
|
||||||
// //jsonWriteStr(configLiveJson, bme280H_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bme280H_value_name, String(value));
|
||||||
// //eventGen(bme280H_value_name, "");
|
// //eventGen2(bme280H_value_name, "");
|
||||||
// // publishStatus(bme280H_value_name, String(value));
|
// // publishStatus(bme280H_value_name, String(value));
|
||||||
// //SerialPrint("I", "Sensor", "'" + bme280H_value_name + "' data: " + String(value));
|
// //SerialPrint("I", "Sensor", "'" + bme280H_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
@@ -397,7 +397,7 @@
|
|||||||
// float value = bme.readAltitude(1013.25);
|
// float value = bme.readAltitude(1013.25);
|
||||||
// //jsonWriteStr(configLiveJson, bme280A_value_name, String(value, 2));
|
// //jsonWriteStr(configLiveJson, bme280A_value_name, String(value, 2));
|
||||||
//
|
//
|
||||||
// //eventGen(bme280A_value_name, "");
|
// //eventGen2(bme280A_value_name, "");
|
||||||
//
|
//
|
||||||
// // publishStatus(bme280A_value_name, String(value));
|
// // publishStatus(bme280A_value_name, String(value));
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -43,28 +43,70 @@ void handleTelegram() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void telegramMsgParse(String msg) {
|
void telegramMsgParse(String msg) {
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
if (msg.indexOf("set") != -1) {
|
||||||
if (msg.indexOf("order") != -1) {
|
msg = deleteBeforeDelimiter(msg, "_");
|
||||||
msg = deleteBeforeDelimiter(msg, " ");
|
msg.replace("_", " ");
|
||||||
orderBuf += String(msg) + ",";
|
orderBuf += 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));
|
||||||
}
|
}
|
||||||
else if (msg.indexOf("get") != -1) {
|
else if (msg.indexOf("get") != -1) {
|
||||||
msg = deleteBeforeDelimiter(msg, " ");
|
msg = deleteBeforeDelimiter(msg, "_");
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), jsonReadStr(configLiveJson, msg));
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), jsonReadStr(configLiveJson, msg));
|
||||||
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
||||||
|
}
|
||||||
|
else if (msg.indexOf("all") != -1) {
|
||||||
|
String list = returnListOfParams();
|
||||||
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list);
|
||||||
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "wrong order, use 'get id' to get value, or 'order id value' to send order");
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "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 msg = sCmd.next();
|
String msg = sCmd.next();
|
||||||
|
String type = sCmd.next();
|
||||||
msg.replace("#", " ");
|
msg.replace("#", " ");
|
||||||
|
if (type == "1") {
|
||||||
|
static String prevMsg;
|
||||||
|
if (prevMsg != msg) {
|
||||||
|
prevMsg = msg;
|
||||||
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 if (type == "2") {
|
||||||
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||||
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool isTelegramEnabled() {
|
bool isTelegramEnabled() {
|
||||||
return jsonReadBool(configSetupJson, "telegonof");
|
return jsonReadBool(configSetupJson, "telegonof");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String returnListOfParams() {
|
||||||
|
String cmdStr = readFile(DEVICE_CONFIG_FILE, 4096);
|
||||||
|
cmdStr += "\r\n";
|
||||||
|
cmdStr.replace("\r\n", "\n");
|
||||||
|
cmdStr.replace("\r", "\n");
|
||||||
|
int count = 0;
|
||||||
|
String out;
|
||||||
|
while (cmdStr.length()) {
|
||||||
|
String buf = selectToMarker(cmdStr, "\n");
|
||||||
|
count++;
|
||||||
|
if (count > 1) {
|
||||||
|
String id = selectFromMarkerToMarker(buf, ";", 2);
|
||||||
|
String value = jsonReadStr(configLiveJson, id);
|
||||||
|
String page = selectFromMarkerToMarker(buf, ";", 4);
|
||||||
|
page.replace("#", " ");
|
||||||
|
String name = selectFromMarkerToMarker(buf, ";", 5);
|
||||||
|
name.replace("#", " ");
|
||||||
|
out += page + " " + " " + name + " " + value + "\n";
|
||||||
|
}
|
||||||
|
cmdStr = deleteBeforeDelimiter(cmdStr, "\n");
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ void Timer_countdown_init() {
|
|||||||
if (time == 0) {
|
if (time == 0) {
|
||||||
delTimer(String(number));
|
delTimer(String(number));
|
||||||
jsonWriteStr(configLiveJson, "timer" + String(number), "0");
|
jsonWriteStr(configLiveJson, "timer" + String(number), "0");
|
||||||
eventGen("timer", String(number));
|
eventGen2("timer", String(number));
|
||||||
} else {
|
} else {
|
||||||
time--;
|
time--;
|
||||||
addTimer(String(number), String(time));
|
addTimer(String(number), String(time));
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ String addNewDevice() {
|
|||||||
//==============================================
|
//==============================================
|
||||||
jsonWriteStr(json, "uniqueId", mac);
|
jsonWriteStr(json, "uniqueId", mac);
|
||||||
jsonWriteStr(json, "name", FIRMWARE_NAME);
|
jsonWriteStr(json, "name", FIRMWARE_NAME);
|
||||||
jsonWriteInt(json, "model", FIRMWARE_VERSION);
|
jsonWriteStr(json, "model", getChipId());
|
||||||
//==============================================
|
//==============================================
|
||||||
http.begin(client, serverIP + F(":8082/api/devices/"));
|
http.begin(client, serverIP + F(":8082/api/devices/"));
|
||||||
http.setAuthorization("admin", "admin");
|
http.setAuthorization("admin", "admin");
|
||||||
@@ -141,7 +141,8 @@ String updateDeviceStatus() {
|
|||||||
"&uptime=" + timeNow->getUptime() +
|
"&uptime=" + timeNow->getUptime() +
|
||||||
"&uptimeTotal=" + getUptimeTotal() +
|
"&uptimeTotal=" + getUptimeTotal() +
|
||||||
"&version=" + FIRMWARE_VERSION +
|
"&version=" + FIRMWARE_VERSION +
|
||||||
"&resetsTotal=" + String(getCurrentNumber("stat.txt")) + "");
|
"&resetsTotal=" + String(getCurrentNumber("stat.txt")) +
|
||||||
|
"&heap=" + String(ESP.getFreeHeap()) + "");
|
||||||
if (httpCode > 0) {
|
if (httpCode > 0) {
|
||||||
ret = httpCode;
|
ret = httpCode;
|
||||||
if (httpCode == HTTP_CODE_OK) {
|
if (httpCode == HTTP_CODE_OK) {
|
||||||
|
|||||||
@@ -20,8 +20,13 @@ void inputTimeSet() {
|
|||||||
void handle_time_init() {
|
void handle_time_init() {
|
||||||
ts.add(
|
ts.add(
|
||||||
TIME, 1000, [&](void*) {
|
TIME, 1000, [&](void*) {
|
||||||
jsonWriteStr(configLiveJson, "timenow", timeNow->getTime());
|
String timenow = timeNow->getTimeWOsec();
|
||||||
eventGen("timenow", "");
|
static String prevTime;
|
||||||
|
if (prevTime != timenow) {
|
||||||
|
prevTime = timenow;
|
||||||
|
jsonWriteStr(configLiveJson, "timenow", timenow);
|
||||||
|
eventGen2("timenow", timenow);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ void SensorDallas::loop() {
|
|||||||
void SensorDallas::readDallas() {
|
void SensorDallas::readDallas() {
|
||||||
sensors.requestTemperaturesByIndex(_index);
|
sensors.requestTemperaturesByIndex(_index);
|
||||||
float value = sensors.getTempCByIndex(_index);
|
float value = sensors.getTempCByIndex(_index);
|
||||||
eventGen(_key, "");
|
eventGen2(_key, String(value));
|
||||||
jsonWriteStr(configLiveJson, _key, String(value));
|
jsonWriteStr(configLiveJson, _key, String(value));
|
||||||
publishStatus(_key, String(value));
|
publishStatus(_key, String(value));
|
||||||
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(value));
|
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(value));
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "Bus.h"
|
#include "Bus.h"
|
||||||
#include "Class/CallBackTest.h"
|
#include "Class/CallBackTest.h"
|
||||||
#include "Class/NotAsync.h"
|
#include "Class/NotAsync.h"
|
||||||
#include "Class/ScenarioClass.h"
|
#include "Class/ScenarioClass3.h"
|
||||||
#include "Cmd.h"
|
#include "Cmd.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user