Add command `Rule0`

Add command ``Rule0`` to change global rule parameters
This commit is contained in:
Theo Arends 2020-05-19 11:15:31 +02:00
parent 70f51b78fe
commit e1fbf64037
5 changed files with 29 additions and 4 deletions

View File

@ -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

View File

@ -2,6 +2,8 @@
### 8.3.1.1 20200518
- Add command ``Rule0`` to change global rule parameters
## Released
### 8.3.1 20200518

View File

@ -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++;
}

View File

@ -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

View File

@ -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