From e1fbf640379c902588486c1427e8825b9ace14a3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 19 May 2020 11:15:31 +0200 Subject: [PATCH] Add command ``Rule0`` Add command ``Rule0`` to change global rule parameters --- RELEASENOTES.md | 2 ++ tasmota/CHANGELOG.md | 2 ++ tasmota/support_command.ino | 4 ++-- tasmota/xdrv_10_rules.ino | 20 ++++++++++++++++++++ tasmota/xdrv_99_debug.ino | 5 +++-- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c55146eaa..71041b5da 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -53,3 +53,5 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ## Changelog ### Version 8.3.1.1 + +- Add command ``Rule0`` to change global rule parameters diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index d24578cc3..e9ec2176d 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -2,6 +2,8 @@ ### 8.3.1.1 20200518 +- Add command ``Rule0`` to change global rule parameters + ## Released ### 8.3.1 20200518 diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index dbcd5a954..f262b5fcb 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1040,7 +1040,7 @@ void CmndModules(void) uint32_t j = i ? midx +1 : 0; if ((ResponseAppend_P(PSTR("\"%d\":\"%s\""), j, AnyModuleName(midx).c_str()) > (LOGSZ - TOPSZ)) || (i == sizeof(kModuleNiceList))) { ResponseJsonEndEnd(); - MqttPublishPrefixTopic_P(RESULT_OR_STAT, UpperCase(XdrvMailbox.command, XdrvMailbox.command)); + MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command); jsflg = false; lines++; } @@ -1149,7 +1149,7 @@ void CmndGpios(void) char stemp1[TOPSZ]; if ((ResponseAppend_P(PSTR("\"%d\":\"%s\""), ridx, GetTextIndexed(stemp1, sizeof(stemp1), midx, kSensorNames)) > (LOGSZ - TOPSZ)) || (i == ARRAY_SIZE(kGpioNiceList) -1)) { ResponseJsonEndEnd(); - MqttPublishPrefixTopic_P(RESULT_OR_STAT, UpperCase(XdrvMailbox.command, XdrvMailbox.command)); + MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command); jsflg = false; lines++; } diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index ddb4de39d..d23f3e122 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -1954,6 +1954,26 @@ void RulesPreprocessCommand(char *pCommands) void CmndRule(void) { + if (0 == XdrvMailbox.index) { + char data = '\0'; + if (XdrvMailbox.data_len > 0) { // Allow show all if 0 + if (!((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 10))) { + if ('"' == XdrvMailbox.data[0]) { + data = '"'; // Save data as XdrvMailbox.data is destroyed + } else { + XdrvMailbox.data_len = 0; // Discard any additional text + } + } + } + for (uint32_t i = 1; i <= MAX_RULE_SETS; i++) { + XdrvMailbox.index = i; + XdrvMailbox.data[0] = data; // Only 0 or " + CmndRule(); + MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command); + } + mqtt_data[0] = '\0'; // Disable further processing + return; + } uint8_t index = XdrvMailbox.index; if ((index > 0) && (index <= MAX_RULE_SETS)) { // if ((XdrvMailbox.data_len > 0) && (XdrvMailbox.data_len < sizeof(Settings.rules[index -1]))) { // TODO postpone size calculation diff --git a/tasmota/xdrv_99_debug.ino b/tasmota/xdrv_99_debug.ino index 672ff17d3..08f451c30 100644 --- a/tasmota/xdrv_99_debug.ino +++ b/tasmota/xdrv_99_debug.ino @@ -45,7 +45,6 @@ #define D_CMND_CFGDUMP "CfgDump" #define D_CMND_CFGPEEK "CfgPeek" #define D_CMND_CFGPOKE "CfgPoke" -#define D_CMND_CFGSHOW "CfgShow" #define D_CMND_CFGXOR "CfgXor" #define D_CMND_CPUCHECK "CpuChk" #define D_CMND_EXCEPTION "Exception" @@ -459,7 +458,9 @@ void CmndCfgXor(void) if (XdrvMailbox.data_len > 0) { Web.config_xor_on_set = XdrvMailbox.payload; } - ResponseCmndNumber(Web.config_xor_on_set); + char temp[10]; + snprintf_P(temp, sizeof(temp), PSTR("0x%02X"), Web.config_xor_on_set); + ResponseCmndChar(temp); } #endif // USE_WEBSERVER