Add command `WebTime <start_pos>,<end_pos>`

- Add command ``WebTime <start_pos>,<end_pos>`` to show part of date and/or time in web gui based on "2017-03-07T11:08:02-07:00"
- Bump version to v2022.01.3
This commit is contained in:
Theo Arends 2022-01-16 16:19:28 +01:00
parent d123f8dbc5
commit 4df42a28f5
7 changed files with 45 additions and 8 deletions

View File

@ -3,7 +3,15 @@ All notable changes to this project will be documented in this file.
## [Unreleased] - Development
## [2022.01.2]
## [2022.01.3]
### Added
- Command ``WebTime <start_pos>,<end_pos>`` to show part of date and/or time in web gui based on "2017-03-07T11:08:02-07:00"
### Changed
### Fixed
## [2022.01.2] 20220116
### Added
- Tasmota favicon to webbrowser tab (#14322)
- Commands for ESP32 ethernet configuration ``EthIpAddress``, ``EthGateway``, ``EthSubnetmask``, ``EthDnsServer1`` and ``EthDnsServer2`` (#14385)
@ -12,9 +20,6 @@ All notable changes to this project will be documented in this file.
### Changed
- IRremoteESP8266 library from v2.8.0 to v2.8.1
### Fixed
## [2022.01.1] 20220107
### Added
- Experimental ADE7953 (Shelly EM) reset on restart (#14261)

View File

@ -100,9 +100,10 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
[Complete list](BUILDS.md) of available feature and sensors.
## Changelog v2022.01.2
## Changelog v2022.01.3
### Added
- Command ``SSerialConfig <serialconfig>`` to change Serial Bridge configuration
- Command ``WebTime <start_pos>,<end_pos>`` to show part of date and/or time in web gui based on "2017-03-07T11:08:02-07:00"
- Command ``SspmMap 2,1,..`` to map Sonoff SPM scanned module to physical module [#14281](https://github.com/arendst/Tasmota/issues/14281)
- Commands for ESP32 ethernet configuration ``EthIpAddress``, ``EthGateway``, ``EthSubnetmask``, ``EthDnsServer1`` and ``EthDnsServer2`` [#14385](https://github.com/arendst/Tasmota/issues/14385)
- Support for Eastron SDM230 modBus energy meter [#13443](https://github.com/arendst/Tasmota/issues/13443)

View File

@ -422,6 +422,7 @@
#define D_CMND_WEBQUERY "WebQuery"
#define D_CMND_WEBCOLOR "WebColor"
#define D_CMND_WEBBUTTON "WebButton"
#define D_CMND_WEBTIME "WebTime"
#define D_CMND_WEBSENSOR "WebSensor"
#define D_CMND_WEBGETCONFIG "WebGetConfig"
#define D_CMND_EMULATION "Emulation"

View File

@ -487,8 +487,10 @@ typedef struct {
int32_t energy_kWhyesterday_ph[3]; // 320
int32_t energy_kWhtotal_ph[3]; // 32C
uint8_t free_338[6]; // 338
uint8_t free_338[4]; // 338
uint8_t web_time_start; // 33C
uint8_t web_time_end; // 33D
uint8_t sserial_config; // 33E
uint8_t tuyamcu_topic; // 33F Manage tuyaSend topic. ex_energy_power_delta on 6.6.0.20, replaced on 8.5.0.1
uint16_t domoticz_update_timer; // 340

View File

@ -1475,6 +1475,10 @@ void SettingsDelta(void) {
if (Settings->version < 0x0A010003) {
Settings->sserial_config = Settings->serial_config;
}
if (Settings->version < 0x14160103) {
Settings->web_time_start = 0;
Settings->web_time_end = 0;
}
Settings->version = VERSION;
SettingsSave(1);

View File

@ -20,6 +20,6 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_
const uint32_t VERSION = 0x14160102; // 2022.01.2
const uint32_t VERSION = 0x14160103; // 2022.01.3
#endif // _TASMOTA_VERSION_H_

View File

@ -875,7 +875,7 @@ void WSContentSendStyle_P(const char* formatP, ...) {
// SetOption53 - Show hostname and IP address in GUI main menu
#if (RESTART_AFTER_INITIAL_WIFI_CONFIG)
if (Settings->flag3.gui_hostname_ip) {
if (Settings->flag3.gui_hostname_ip) { // SetOption53 - (GUI) Show hostname and IP address in GUI main menu
#else
if ( Settings->flag3.gui_hostname_ip || ( (WiFi.getMode() == WIFI_AP_STA) && (!Web.initial_config) ) ) {
#endif
@ -1406,6 +1406,9 @@ bool HandleRootStatusRefresh(void)
WSContentBegin(200, CT_HTML);
#endif // USE_WEB_SSE
WSContentSend_P(PSTR("{t}"));
if (Settings->web_time_end) {
WSContentSend_P(PSTR("{s}" D_TIMER_TIME "{m}%s{e}"), GetDateAndTime(DT_LOCAL).substring(Settings->web_time_start, Settings->web_time_end).c_str());
}
XsnsCall(FUNC_WEB_SENSOR);
XdrvCall(FUNC_WEB_SENSOR);
@ -3281,6 +3284,7 @@ const char kWebCmndStatus[] PROGMEM = D_JSON_DONE "|" D_JSON_WRONG_PARAMETERS "|
;
const char kWebCommands[] PROGMEM = "|" // No prefix
D_CMND_WEBTIME "|"
#ifdef USE_EMULATION
D_CMND_EMULATION "|"
#endif
@ -3298,6 +3302,7 @@ const char kWebCommands[] PROGMEM = "|" // No prefix
;
void (* const WebCommand[])(void) PROGMEM = {
&CmndWebTime,
#ifdef USE_EMULATION
&CmndEmulation,
#endif
@ -3318,6 +3323,25 @@ void (* const WebCommand[])(void) PROGMEM = {
* Commands
\*********************************************************************************************/
void CmndWebTime(void) {
// 2017-03-07T11:08:02-07:00
// 0123456789012345678901234
//
// WebTime 0,16 = 2017-03-07T11:08 - No seconds
// WebTime 11,19 = 11:08:02
uint32_t values[2] = { 0 };
String datetime = GetDateAndTime(DT_LOCAL);
if (ParseParameters(2, values) > 1) {
Settings->web_time_start = values[0];
Settings->web_time_end = values[1];
if (Settings->web_time_end > datetime.length()) { Settings->web_time_end = datetime.length(); }
if (Settings->web_time_start >= Settings->web_time_end) { Settings->web_time_start = 0; }
}
Response_P(PSTR("{\"%s\":[%d,%d],\"Time\":\"%s\"}"),
XdrvMailbox.command, Settings->web_time_start, Settings->web_time_end,
datetime.substring(Settings->web_time_start, Settings->web_time_end).c_str());
}
#ifdef USE_EMULATION
void CmndEmulation(void)
{