presets support

This commit is contained in:
Dmitry Borisenko
2020-02-18 16:22:17 +03:00
parent 8d16ae9188
commit a29a8b246c
16 changed files with 256 additions and 1 deletions

View File

@@ -5,7 +5,6 @@ void All_init() {
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
server.on("/scenario", HTTP_GET, [](AsyncWebServerRequest * request) {
if (request->hasArg("status")) {
jsonWrite(configSetup, "scenario", request->getParam("status")->value());
@@ -24,6 +23,8 @@ void All_init() {
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
prsets_init();
Device_init();
Scenario_init();
Timer_countdown_init();
@@ -51,12 +52,75 @@ void Scenario_init() {
}
}
void prsets_init() {
//part 1===============================================================================
server.on("/relay", HTTP_GET, [](AsyncWebServerRequest * request) {
writeFile("firmware.config.txt", readFile("configs/relay.config.txt", 2048));
writeFile("firmware.scenario.txt", readFile("configs/relay.scenario.txt", 2048));
Device_init();
Scenario_init();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
server.on("/relay_timer", HTTP_GET, [](AsyncWebServerRequest * request) {
writeFile("firmware.config.txt", readFile("configs/relay_t.config.txt", 2048));
writeFile("firmware.scenario.txt", readFile("configs/relay_t.scenario.txt", 2048));
Device_init();
Scenario_init();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
server.on("/relay_countdown", HTTP_GET, [](AsyncWebServerRequest * request) {
writeFile("firmware.config.txt", readFile("configs/relay_c.config.txt", 2048));
writeFile("firmware.scenario.txt", readFile("configs/relay_c.scenario.txt", 2048));
Device_init();
Scenario_init();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
server.on("/relay_several", HTTP_GET, [](AsyncWebServerRequest * request) {
writeFile("firmware.config.txt", readFile("configs/relay_s.config.txt", 2048));
writeFile("firmware.scenario.txt", readFile("configs/relay_s.scenario.txt", 2048));
Device_init();
Scenario_init();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
//part 2===============================================================================
server.on("/termostat", HTTP_GET, [](AsyncWebServerRequest * request) {
writeFile("firmware.config.txt", readFile("configs/termostat.config.txt", 2048));
writeFile("firmware.scenario.txt", readFile("configs/termostat.scenario.txt", 2048));
Device_init();
Scenario_init();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
server.on("/dht", HTTP_GET, [](AsyncWebServerRequest * request) {
writeFile("firmware.config.txt", readFile("configs/dht.config.txt", 2048));
writeFile("firmware.scenario.txt", readFile("configs/dht.scenario.txt", 2048));
Device_init();
Scenario_init();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
server.on("/default", HTTP_GET, [](AsyncWebServerRequest * request) {
writeFile("firmware.config.txt", readFile("configs/firmware.config.txt", 2048));
writeFile("firmware.scenario.txt", readFile("configs/firmware.scenario.txt", 2048));
Device_init();
Scenario_init();
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
});
}
void up_time() {
uint32_t ss = millis() / 1000;
uint32_t mm = ss / 60;
uint32_t hh = mm / 60;
uint32_t dd = hh / 24;
if (ss != 0) {
Serial.println(String(ss) + " sec");
jsonWrite(configJson, "uptime", String(ss) + " sec");
}
if (mm != 0) {
Serial.println(String(mm) + " min");
jsonWrite(configJson, "uptime", String(mm) + " min");

View File

@@ -0,0 +1,5 @@
dhtT DHT11 2 Температура#DHT,#t°C Датчики any-data 1
dhtH DHT11 2 Влажность#DHT,#% Датчики any-data 2
dhtComfort Степень#комфорта: Датчики 3
dhtPerception Восприятие: Датчики 4
dhtDewpoint Точка#росы: Датчики 5

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,30 @@
button 1 na Включить#все Реле 0 1
button 2 13 Прихожая Реле 0 2
button 3 14 Кухня Реле 0 3
pwm 1 3 Яркость#коредор: Реле 1023 4
pwm 2 4 Яркость#ванная: Реле 510 5
//---------------------------------------------------------------------
//analog 0 Аналоговый#вход,#% Датчики progress-round 1 1024 1 1024 6
inputDigit digit1 При#скольки#включить? Датчики 10 7
inputDigit digit2 При#скольки#выключить? Датчики 0 8
button 4 na Нагреватель Датчики 0 9
//dallas 2 Водонагреватель,#t°C Датчики any-data 10
//dhtT DHT11 2 Температура#DHT,#t°C Датчики any-data 11
//dhtH DHT11 2 Влажность#DHT,#% Датчики any-data 12
//dhtComfort Степень#комфорта: Датчики 12
//dhtPerception Восприятие: Датчики 13
//dhtDewpoint Точка#росы: Датчики 14
//level Вода#в#баке,#% Датчики any-data 125 20 15
//---------------------------------------------------------------------
button 5 na Вкл#обратный#таймер Таймеры 0 16
inputDigit digit3 Через#сколько#секунд#включить? Таймеры 5 17
button 6 na Включится#по#таймеру Таймеры 0 18
inputTime time1 Во#сколько#включить? Таймеры 20.30 19
button 7 5 Включится#по#таймеру Таймеры 0 20
//---------------------------------------------------------------------
switch 1 0 20
textSet 1 неопределено
text 1 Квартира Двери 22
//---------------------------------------------------------------------
button 8 scenario Вкл#выкл#все#сценарии Сценарии 1 23
button 9 line1,line2, Вкл#выкл#выбранные#сценарии Сценарии 1 24

View File

@@ -0,0 +1,32 @@
button1 = 1
buttonSet 2 1
buttonSet 3 1
pwmSet 2 1024
end
button1 = 0
buttonSet 2 0
buttonSet 3 0
pwmSet 2 0
end
analog > digit1
buttonSet 4 1
end
analog < digit2
buttonSet 4 0
end
button5 = 1
timerStart 1 digit3 sec
end
timer1 = 0
buttonSet 6 1
end
timenow = time1
buttonSet 7 1
end
switch1 = 1
textSet 1 закрыто-time
push закрыто вход
end
switch1 = 0
textSet 1 открыто-time
end

View File

@@ -0,0 +1 @@
button 1 5 Включить#реле Реле 0 1

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,2 @@
button 1 5 Вкл#на#время Таймеры 0 1
inputDigit digit1 Через#сколько#секунд#выключить? Таймеры 5 2

View File

@@ -0,0 +1,6 @@
button1 = 1
timerStart 1 digit1 sec
end
timer1 = 0
buttonSet 1 0
end

View File

@@ -0,0 +1 @@
button 1 na Включить#все Освещение 0 1

View File

@@ -0,0 +1,8 @@
button1 = 1
pinSet 5 1
pinSet 13 0
end
button1 = 0
pinSet 5 0
pinSet 13 1
end

View File

@@ -0,0 +1,3 @@
inputTime time1 Во#сколько#включить? Таймеры 20.30 1
inputTime time2 Во#сколько#выключить? Таймеры 20.35 2
button 1 5 Включится#по#таймеру Таймеры 0 3

View File

@@ -0,0 +1,6 @@
timenow = time1
buttonSet 1 1
end
timenow = time2
buttonSet 1 0
end

View File

@@ -0,0 +1,4 @@
dallas 2 Водонагреватель,#t°C Термостат any-data 1
inputDigit digit1 При#скольки#включить? Термостат 40 2
inputDigit digit2 При#скольки#выключить? Термостат 20 3
button 1 5 Нагреватель Термостат 0 4

View File

@@ -0,0 +1,6 @@
dallas > digit1
buttonSet 1 1
end
dallas < digit2
buttonSet 1 0
end

View File

@@ -27,6 +27,87 @@
{
"type": "hr"
},
{
"type": "h2",
"title": "Чтобы превратить ESP во что либо из списка, нажмите на соответствующию кнопку:"
},
{
"type": "h4",
"title": "Раздел 1. Управление нагрузкой"
},
{
"type": "button",
"title": "Включение выключение реле",
"action": "/relay",
"class": "btn btn-block btn-primary"
},
{
"type": "button",
"title": "Включение выключение реле в определенное время",
"action": "/relay_timer",
"class": "btn btn-block btn-primary"
},
{
"type": "button",
"title": "Включение выключение реле на определенный период времени",
"action": "/relay_countdown",
"class": "btn btn-block btn-primary"
},
{
"type": "button",
"title": "Включение выключение нескольких реле одной кнопкой в приложении",
"action": "/relay_several",
"class": "btn btn-block btn-primary"
},
{
"type": "h4",
"title": "Раздел 2. Сенсоры"
},
{
"type": "button",
"title": "Термостат на ds18b20",
"action": "/termostat",
"class": "btn btn-block btn-primary"
},
{
"type": "button",
"title": "Датчик движения включающий свет",
"action": "/moution-relay",
"class": "btn btn-block btn-primary"
},
{
"type": "button",
"title": "Охранный датчик движения",
"action": "/moution-security",
"class": "btn btn-block btn-primary"
},
{
"type": "button",
"title": "Выключатель",
"action": "/switch",
"class": "btn btn-block btn-primary"
},
{
"type": "button",
"title": "Чтение датчика dht",
"action": "/dht",
"class": "btn btn-block btn-primary"
},
{
"type": "hr"
},
{
"type": "button",
"title": "Сбросить сценарии и конфигурации по умолчанию",
"action": "/default",
"class": "btn btn-block btn-danger"
},
{
"type": "hr"
},
{
"type": "h2",
"title": "Конфигурация устройства"
@@ -68,6 +149,10 @@
"action": "/scenario?status=1",
"class":"btn btn-block btn-success"
},
{
"type": "hr"
},
{
"type": "h2",
"title": "Данные модулей"