From 2832ed914bbd57b16820f5c3ffd469862bda58f5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:55:25 +0100 Subject: [PATCH] Change command ``TimedPower`` Change command ``TimedPower`` from erasing all timers to showing remaining timers --- CHANGELOG.md | 2 ++ RELEASENOTES.md | 1 + tasmota/tasmota_support/support_command.ino | 27 +++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ae70cce..9b76fb816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file. ### Changed - ESP32 platform update from 2024.01.00 to 2024.01.01 (#20508) - IP stack compatible with new Core3 IPv6 implementation (#20509) +- Command ``TimedPower`` from erasing all timers to showing remaining timers ### Fixed - Scripter memory leak in `>w x` (#20473) @@ -27,6 +28,7 @@ All notable changes to this project will be documented in this file. - GPIO Viewer single instance - Zigbee ramdom crash in main page (#20481) - Web file upload response on upload error (#20340) +- ESP32 shutter exception 6 (divide by zero) on ``ShutterMode 4`` (#20524) ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 183c4adeb..9d1d594a4 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -173,6 +173,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Scripter memory leak in `>w x` (#20473)[#20473](https://github.com/arendst/Tasmota/issues/20473) - Zigbee ramdom crash in main page (#20481)[#20473](https://github.com/arendst/Tasmota/issues/20481) - ESP32 piezo ceramic buzzer doesn't buzz [#20118](https://github.com/arendst/Tasmota/issues/20118) +- ESP32 shutter exception 6 (divide by zero) on ``ShutterMode 4`` [#20524](https://github.com/arendst/Tasmota/issues/20524) - ESP32 Zigbee Aqara attributes [#20452](https://github.com/arendst/Tasmota/issues/20452) - LVGL fix type for lv_imgbtn [#20354](https://github.com/arendst/Tasmota/issues/20354) - Berry claiming UART0 if needed [#20324](https://github.com/arendst/Tasmota/issues/20324) diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index fcc5e3725..cefea6cb3 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -535,6 +535,27 @@ void ResetTimedCmnd(const char *command) { } } +void ShowTimedCmnd(const char *command) { + bool found = false; + uint32_t now = millis(); + Response_P(PSTR("{\"%s\":"), XdrvMailbox.command); + for (uint32_t i = 0; i < MAX_TIMED_CMND; i++) { + if (TasmotaGlobal.timed_cmnd[i].time != 0) { + if (!strncmp(command, TasmotaGlobal.timed_cmnd[i].command.c_str(), strlen(command))) { + // Stored command starts with command + ResponseAppend_P(PSTR("%s"), (found) ? "," : "["); + found = true; + ResponseAppend_P(PSTR("{\"" D_JSON_REMAINING "\":%d,\"" D_JSON_COMMAND "\":\"%s\"}"), TasmotaGlobal.timed_cmnd[i].time - now, TasmotaGlobal.timed_cmnd[i].command.c_str()); + } + } + } + if (found) { + ResponseAppend_P(PSTR("]}")); + } else { + ResponseAppend_P(PSTR("\"" D_JSON_EMPTY "\"}")); + } +} + void LoopTimedCmnd(void) { uint32_t now = millis(); for (uint32_t i = 0; i < MAX_TIMED_CMND; i++) { @@ -755,7 +776,7 @@ void CmndTimedPower(void) { /* Allow timed power changes on a 50ms granularity TimedPower [,0|1|2|3] - TimedPower - Clear active power timers + TimedPower - Show remaining timers TimedPower 2000 - Turn power1 on and then off after 2 seconds TimedPower1 - Clear active Power1 timers TimedPower1 0 - Stop timer and perform timed action @@ -788,7 +809,9 @@ void CmndTimedPower(void) { } } else { if (!XdrvMailbox.usridx) { - ResetTimedCmnd(D_CMND_POWER); // Remove all POWER timed command +// ResetTimedCmnd(D_CMND_POWER); // Remove all POWER timed command + ShowTimedCmnd(D_CMND_POWER); // Show remaining timers + return; } else { char cmnd[CMDSZ]; snprintf_P(cmnd, sizeof(cmnd), PSTR(D_CMND_POWER "%d"), XdrvMailbox.index);