mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 06:47:17 +00:00
Fix possible rule issue
This commit is contained in:
parent
9dabc9ea69
commit
ca61cb06d0
@ -138,6 +138,7 @@ struct {
|
||||
int16_t save_data_counter; // Counter and flag for config save to Flash
|
||||
RulesBitfield rules_flag; // Rule state flags (16 bits)
|
||||
|
||||
bool rule_teleperiod; // Process rule based on teleperiod data using prefix TELE-
|
||||
bool serial_local; // Handle serial locally
|
||||
bool fallback_topic_flag; // Use Topic or FallbackTopic
|
||||
bool backlog_mutex; // Command backlog pending
|
||||
|
@ -174,7 +174,6 @@ struct RULES {
|
||||
uint16_t last_minute = 60;
|
||||
uint16_t vars_event = 0; // Bitmask supporting MAX_RULE_VARS bits
|
||||
uint16_t mems_event = 0; // Bitmask supporting MAX_RULE_MEMS bits
|
||||
bool teleperiod = false;
|
||||
bool busy = false;
|
||||
bool no_execute = false; // Don't actually execute rule commands
|
||||
|
||||
@ -420,7 +419,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all
|
||||
|
||||
// Step1: Analyse rule
|
||||
String rule_expr = rule; // "TELE-INA219#CURRENT>0.100"
|
||||
if (Rules.teleperiod) {
|
||||
if (TasmotaGlobal.rule_teleperiod) {
|
||||
int ppos = rule_expr.indexOf(F("TELE-")); // "TELE-INA219#CURRENT>0.100" or "INA219#CURRENT>0.100"
|
||||
if (ppos == -1) { return false; } // No pre-amble in rule
|
||||
rule_expr = rule.substring(5); // "INA219#CURRENT>0.100" or "SYSTEM#BOOT"
|
||||
@ -854,7 +853,7 @@ void RulesInit(void)
|
||||
bitWrite(Settings.rule_once, i, 0);
|
||||
}
|
||||
}
|
||||
Rules.teleperiod = false;
|
||||
TasmotaGlobal.rule_teleperiod = false;
|
||||
}
|
||||
|
||||
void RulesEvery50ms(void)
|
||||
@ -2340,9 +2339,7 @@ bool Xdrv10(uint8_t function)
|
||||
result = DecodeCommand(kRulesCommands, RulesCommand);
|
||||
break;
|
||||
case FUNC_RULES_PROCESS:
|
||||
Rules.teleperiod = (XdrvMailbox.index); // Signal teleperiod event
|
||||
result = RulesProcess();
|
||||
Rules.teleperiod = false;
|
||||
break;
|
||||
case FUNC_SAVE_BEFORE_RESTART:
|
||||
RulesSaveBeforeRestart();
|
||||
|
@ -7855,7 +7855,7 @@ bool Xdrv10(uint8_t function)
|
||||
break;
|
||||
case FUNC_RULES_PROCESS:
|
||||
if (bitRead(Settings.rule_enabled, 0)) {
|
||||
if (XdrvMailbox.index) { // Signal teleperiod event
|
||||
if (TasmotaGlobal.rule_teleperiod) { // Signal teleperiod event
|
||||
if (TasmotaGlobal.mqtt_data[0]) {
|
||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data);
|
||||
}
|
||||
|
@ -1080,16 +1080,15 @@ void XsnsDriverState(void)
|
||||
/*********************************************************************************************/
|
||||
|
||||
bool XdrvRulesProcess(bool teleperiod) {
|
||||
XdrvMailbox.index = teleperiod; // Signal teleperiod event
|
||||
TasmotaGlobal.rule_teleperiod = teleperiod; // Signal teleperiod event
|
||||
bool rule_handled = XdrvCallDriver(10, FUNC_RULES_PROCESS);
|
||||
#ifdef USE_BERRY
|
||||
// events are passed to both Rules engine AND Berry engine
|
||||
bool rule_handled = XdrvCallDriver(10, FUNC_RULES_PROCESS);
|
||||
XdrvMailbox.index = teleperiod; // Signal teleperiod event
|
||||
bool berry_handled = XdrvCallDriver(52, FUNC_RULES_PROCESS);
|
||||
return rule_handled || berry_handled;
|
||||
#else
|
||||
return XdrvCallDriver(10, FUNC_RULES_PROCESS);
|
||||
rule_handled |= berry_handled;
|
||||
#endif
|
||||
TasmotaGlobal.rule_teleperiod = false;
|
||||
return rule_handled;
|
||||
}
|
||||
|
||||
#ifdef USE_DEBUG_DRIVER
|
||||
|
Loading…
x
Reference in New Issue
Block a user