mirror of https://github.com/arendst/Tasmota.git
Extent commands Var and Mem with option to show all parameters at once
Extent commands Var and Mem with option to show all parameters at once (#6107)
This commit is contained in:
parent
64faec9e5c
commit
1068d59a63
|
@ -398,7 +398,7 @@ struct XDRVMAILBOX {
|
|||
uint16_t payload16;
|
||||
int16_t payload;
|
||||
bool grpflg;
|
||||
uint8_t notused;
|
||||
bool usridx;
|
||||
char *topic;
|
||||
char *data;
|
||||
} XdrvMailbox;
|
||||
|
|
|
@ -478,7 +478,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
uint8_t lines = 1;
|
||||
bool jsflg = false;
|
||||
bool grpflg = false;
|
||||
// bool user_append_index = false;
|
||||
bool user_index = false;
|
||||
uint32_t i = 0;
|
||||
uint32_t index;
|
||||
uint32_t address;
|
||||
|
@ -520,7 +520,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
}
|
||||
if (i < strlen(type)) {
|
||||
index = atoi(type +i);
|
||||
// user_append_index = true;
|
||||
user_index = true;
|
||||
}
|
||||
type[i] = '\0';
|
||||
}
|
||||
|
@ -556,6 +556,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
XdrvMailbox.payload16 = payload16;
|
||||
XdrvMailbox.payload = payload;
|
||||
XdrvMailbox.grpflg = grpflg;
|
||||
XdrvMailbox.usridx = user_index;
|
||||
XdrvMailbox.topic = type;
|
||||
XdrvMailbox.data = dataBuf;
|
||||
if (!XdrvCall(FUNC_COMMAND)) {
|
||||
|
@ -604,7 +605,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
}
|
||||
else if ((CMND_POWER == command_code) && (index > 0) && (index <= devices_present)) {
|
||||
if ((payload < 0) || (payload > 4)) { payload = 9; }
|
||||
// Settings.flag.device_index_enable = user_append_index;
|
||||
// Settings.flag.device_index_enable = user_index;
|
||||
ExecuteCommandPower(index, payload, SRC_IGNORE);
|
||||
fallback_topic_flag = false;
|
||||
return;
|
||||
|
|
|
@ -1173,26 +1173,42 @@ bool RulesCommand(void)
|
|||
Response_P(S_JSON_COMMAND_SVALUE, command, D_JSON_DONE);
|
||||
}
|
||||
else if ((CMND_VAR == command_code) && (index > 0) && (index <= MAX_RULE_VARS)) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
if (!XdrvMailbox.usridx) {
|
||||
mqtt_data[0] = '\0';
|
||||
for (uint32_t i = 0; i < MAX_RULE_VARS; i++) {
|
||||
ResponseAppend_P(PSTR("%c\"Var%d\":\"%s\""), (i) ? ',' : '{', i +1, vars[i]);
|
||||
}
|
||||
ResponseJsonEnd();
|
||||
} else {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
#ifdef USE_EXPRESSION
|
||||
dtostrfd(evaluateExpression(XdrvMailbox.data, XdrvMailbox.data_len), Settings.flag2.calc_resolution, vars[index -1]);
|
||||
dtostrfd(evaluateExpression(XdrvMailbox.data, XdrvMailbox.data_len), Settings.flag2.calc_resolution, vars[index -1]);
|
||||
#else
|
||||
strlcpy(vars[index -1], ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(vars[index -1]));
|
||||
strlcpy(vars[index -1], ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(vars[index -1]));
|
||||
#endif //USE_EXPRESSION
|
||||
bitSet(vars_event, index -1);
|
||||
bitSet(vars_event, index -1);
|
||||
}
|
||||
Response_P(S_JSON_COMMAND_INDEX_SVALUE, command, index, vars[index -1]);
|
||||
}
|
||||
Response_P(S_JSON_COMMAND_INDEX_SVALUE, command, index, vars[index -1]);
|
||||
}
|
||||
else if ((CMND_MEM == command_code) && (index > 0) && (index <= MAX_RULE_MEMS)) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
if (!XdrvMailbox.usridx) {
|
||||
mqtt_data[0] = '\0';
|
||||
for (uint32_t i = 0; i < MAX_RULE_MEMS; i++) {
|
||||
ResponseAppend_P(PSTR("%c\"Mem%d\":\"%s\""), (i) ? ',' : '{', i +1, Settings.mems[i]);
|
||||
}
|
||||
ResponseJsonEnd();
|
||||
} else {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
#ifdef USE_EXPRESSION
|
||||
dtostrfd(evaluateExpression(XdrvMailbox.data, XdrvMailbox.data_len), Settings.flag2.calc_resolution, Settings.mems[index -1]);
|
||||
dtostrfd(evaluateExpression(XdrvMailbox.data, XdrvMailbox.data_len), Settings.flag2.calc_resolution, Settings.mems[index -1]);
|
||||
#else
|
||||
strlcpy(Settings.mems[index -1], ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(Settings.mems[index -1]));
|
||||
strlcpy(Settings.mems[index -1], ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, sizeof(Settings.mems[index -1]));
|
||||
#endif //USE_EXPRESSION
|
||||
bitSet(mems_event, index -1);
|
||||
bitSet(mems_event, index -1);
|
||||
}
|
||||
Response_P(S_JSON_COMMAND_INDEX_SVALUE, command, index, Settings.mems[index -1]);
|
||||
}
|
||||
Response_P(S_JSON_COMMAND_INDEX_SVALUE, command, index, Settings.mems[index -1]);
|
||||
}
|
||||
else if (CMND_CALC_RESOLUTION == command_code) {
|
||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 7)) {
|
||||
|
|
Loading…
Reference in New Issue