mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 19:56:30 +00:00
Fix HWRestart on rule event
5.14.0b * Fix Hardware Watchdog restart when using event command (#2853)
This commit is contained in:
parent
ae9f5fd2e3
commit
f3c4001b4a
@ -1,9 +1,11 @@
|
|||||||
/* 5.14.0b
|
/* 5.14.0b
|
||||||
* Add two rule sets of 511 characters using commands rule1, rule2 and rule3
|
* Add two rule sets of 511 characters using commands rule1, rule2 and rule3
|
||||||
|
* Add Ukranian language file
|
||||||
* Add rule support for IrReceive and RfReceive (#2758)
|
* Add rule support for IrReceive and RfReceive (#2758)
|
||||||
* Add command WebSend [<host>(:<port>,<user>:<password>)] <command> (#2821)
|
* Add command WebSend [<host>(:<port>,<user>:<password>)] <command> (#2821)
|
||||||
* Add source information to command execution to be shown with logging option 3 (#2843)
|
* Add source information to command execution to be shown with logging option 3 (#2843)
|
||||||
* Fix some Pow R2 and S31 checksum errors (#1907)
|
* Fix some Pow R2 and S31 checksum errors (#1907)
|
||||||
|
* Fix Hardware Watchdog restart when using event command (#2853)
|
||||||
*
|
*
|
||||||
* 5.14.0a
|
* 5.14.0a
|
||||||
* Add feature information to Status 4
|
* Add feature information to Status 4
|
||||||
|
@ -244,6 +244,29 @@ char* LTrim(char* p)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* RTrim(char* p)
|
||||||
|
{
|
||||||
|
char* q = p + strlen(p) -1;
|
||||||
|
while ((q >= p) && (isblank(*q))) {
|
||||||
|
q--; // Trim trailing spaces
|
||||||
|
}
|
||||||
|
q++;
|
||||||
|
*q = '\0';
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* Trim(char* p)
|
||||||
|
{
|
||||||
|
if (*p == '\0') { return p; }
|
||||||
|
while (isspace(*p)) { p++; } // Trim leading spaces
|
||||||
|
if (*p == '\0') { return p; }
|
||||||
|
char* q = p + strlen(p) -1;
|
||||||
|
while (isspace(*q) && q >= p) { q--; } // Trim trailing spaces
|
||||||
|
q++;
|
||||||
|
*q = '\0';
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
char* NoAlNumToUnderscore(char* dest, const char* source)
|
char* NoAlNumToUnderscore(char* dest, const char* source)
|
||||||
{
|
{
|
||||||
char* write = dest;
|
char* write = dest;
|
||||||
|
@ -90,6 +90,7 @@ uint32_t rules_triggers[MAX_RULE_SETS] = { 0 };
|
|||||||
uint8_t rules_trigger_count[MAX_RULE_SETS] = { 0 };
|
uint8_t rules_trigger_count[MAX_RULE_SETS] = { 0 };
|
||||||
uint8_t rules_teleperiod = 0;
|
uint8_t rules_teleperiod = 0;
|
||||||
|
|
||||||
|
char event_data[100];
|
||||||
char vars[RULES_MAX_VARS][10] = { 0 };
|
char vars[RULES_MAX_VARS][10] = { 0 };
|
||||||
|
|
||||||
/*******************************************************************************************/
|
/*******************************************************************************************/
|
||||||
@ -374,7 +375,26 @@ void RulesEvery50ms()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rules_old_power = rules_new_power;
|
rules_old_power = rules_new_power;
|
||||||
} else {
|
}
|
||||||
|
else if(event_data[0]) {
|
||||||
|
char *event;
|
||||||
|
char *parameter;
|
||||||
|
event = strtok_r(event_data, "=", ¶meter); // event_data = fanspeed=10
|
||||||
|
if (event) {
|
||||||
|
event = Trim(event);
|
||||||
|
if (parameter) {
|
||||||
|
parameter = Trim(parameter);
|
||||||
|
} else {
|
||||||
|
parameter = event + strlen(event); // '\0'
|
||||||
|
}
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"Event\":{\"%s\":\"%s\"}}"), event, parameter);
|
||||||
|
event_data[0] ='\0';
|
||||||
|
RulesProcess();
|
||||||
|
} else {
|
||||||
|
event_data[0] ='\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
rules_quota++;
|
rules_quota++;
|
||||||
if (rules_quota &1) { // Every 100 ms
|
if (rules_quota &1) { // Every 100 ms
|
||||||
mqtt_data[0] = '\0';
|
mqtt_data[0] = '\0';
|
||||||
@ -464,17 +484,7 @@ boolean RulesCommand()
|
|||||||
}
|
}
|
||||||
else if (CMND_EVENT == command_code) {
|
else if (CMND_EVENT == command_code) {
|
||||||
if (XdrvMailbox.data_len > 0) {
|
if (XdrvMailbox.data_len > 0) {
|
||||||
String event = XdrvMailbox.data;
|
strlcpy(event_data, XdrvMailbox.data, sizeof(event_data));
|
||||||
String parameter = "";
|
|
||||||
int pos = event.indexOf('=');
|
|
||||||
if (pos > 0) {
|
|
||||||
parameter = event.substring(pos +1);
|
|
||||||
parameter.trim();
|
|
||||||
event = event.substring(0, pos);
|
|
||||||
}
|
|
||||||
event.trim();
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"Event\":{\"%s\":\"%s\"}}"), event.c_str(), parameter.c_str());
|
|
||||||
RulesProcess();
|
|
||||||
}
|
}
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user