mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Add more validation to timer handling
Add more validation to timer handling
This commit is contained in:
parent
67477b1f4e
commit
823c9a0404
@ -358,6 +358,7 @@
|
||||
#define D_JSON_TIMER_REPEAT "Repeat"
|
||||
#define D_JSON_TIMER_OUTPUT "Output"
|
||||
#define D_JSON_TIMER_POWER "Power"
|
||||
#define D_JSON_TIMER_NO_DEVICE "No GPIO as output configured"
|
||||
#define D_CMND_TIMERS "Timers"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
@ -45,7 +45,7 @@ void WifiWpsStatusCallback(wps_cb_status status);
|
||||
#define USE_HTU // Add I2C code for HTU21/SI7013/SI7020/SI7021 sensor (+1k5 code)
|
||||
#define USE_BMP // Add I2C code for BMP085/BMP180/BMP280/BME280 sensor (+4k code)
|
||||
#define USE_BME680 // Add additional support for BME680 sensor using Adafruit Sensor and BME680 libraries (+6k code)
|
||||
#define USE_SGP30 // Add I2C code for SGP30 sensor (+4k code)
|
||||
#define USE_SGP30 // Add I2C code for SGP30 sensor (+1k1 code)
|
||||
#define USE_BH1750 // Add I2C code for BH1750 sensor (+0k5 code)
|
||||
#define USE_VEML6070 // Add I2C code for VEML6070 sensor (+0k5 code)
|
||||
#define USE_TSL2561 // Add I2C code for TSL2561 sensor using library Adafruit TSL2561 Arduino (+1k2 code)
|
||||
|
@ -181,15 +181,17 @@ const char HTTP_BTN_MENU1[] PROGMEM =
|
||||
"<br/><form action='cs' method='get'><button>" D_CONSOLE "</button></form>";
|
||||
const char HTTP_BTN_RSTRT[] PROGMEM =
|
||||
"<br/><form action='rb' method='get' onsubmit='return confirm(\"" D_CONFIRM_RESTART "\");'><button>" D_RESTART "</button></form>";
|
||||
const char HTTP_BTN_MENU2[] PROGMEM =
|
||||
"<br/><form action='md' method='get'><button>" D_CONFIGURE_MODULE "</button></form>"
|
||||
const char HTTP_BTN_MENU_MODULE[] PROGMEM =
|
||||
"<br/><form action='md' method='get'><button>" D_CONFIGURE_MODULE "</button></form>";
|
||||
#ifdef USE_TIMERS
|
||||
#ifdef USE_TIMERS_WEB
|
||||
"<br/><form action='tm' method='get'><button>" D_CONFIGURE_TIMER "</button></form>"
|
||||
const char HTTP_BTN_MENU_TIMER[] PROGMEM =
|
||||
"<br/><form action='tm' method='get'><button>" D_CONFIGURE_TIMER "</button></form>";
|
||||
#endif // USE_TIMERS_WEB
|
||||
#endif // USE_TIMERS
|
||||
const char HTTP_BTN_MENU_WIFI[] PROGMEM =
|
||||
"<br/><form action='w0' method='get'><button>" D_CONFIGURE_WIFI "</button></form>";
|
||||
const char HTTP_BTN_MENU3[] PROGMEM =
|
||||
const char HTTP_BTN_MENU_MQTT[] PROGMEM =
|
||||
"<br/><form action='mq' method='get'><button>" D_CONFIGURE_MQTT "</button></form>"
|
||||
#ifdef USE_DOMOTICZ
|
||||
"<br/><form action='dm' method='get'><button>" D_CONFIGURE_DOMOTICZ "</button></form>"
|
||||
@ -629,10 +631,14 @@ void HandleConfiguration()
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURATION));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += FPSTR(HTTP_BTN_MENU2);
|
||||
if (Settings.flag.mqtt_enabled) {
|
||||
page += FPSTR(HTTP_BTN_MENU3);
|
||||
}
|
||||
page += FPSTR(HTTP_BTN_MENU_MODULE);
|
||||
#ifdef USE_TIMERS
|
||||
#ifdef USE_TIMERS_WEB
|
||||
if (devices_present) page += FPSTR(HTTP_BTN_MENU_TIMER);
|
||||
#endif // USE_TIMERS_WEB
|
||||
#endif // USE_TIMERS
|
||||
page += FPSTR(HTTP_BTN_MENU_WIFI);
|
||||
if (Settings.flag.mqtt_enabled) page += FPSTR(HTTP_BTN_MENU_MQTT);
|
||||
page += FPSTR(HTTP_BTN_MENU4);
|
||||
page += FPSTR(HTTP_BTN_MAIN);
|
||||
ShowPage(page);
|
||||
|
@ -97,6 +97,7 @@ boolean TimerCommand()
|
||||
Settings.timer[index -1].data = Settings.timer[XdrvMailbox.payload -1].data; // Copy timer
|
||||
}
|
||||
} else {
|
||||
if (devices_present) {
|
||||
StaticJsonBuffer<128> jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.parseObject(dataBufUc);
|
||||
if (!root.success()) {
|
||||
@ -157,6 +158,10 @@ boolean TimerCommand()
|
||||
|
||||
index++;
|
||||
}
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_TIMER "%d\":\"" D_JSON_TIMER_NO_DEVICE "\"}"), index); // No outputs defined so nothing to control
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user