mirror of https://github.com/arendst/Tasmota.git
Merge pull request #9986 from pcdiem/pwm1
Support rules that override button holds
This commit is contained in:
commit
44710e7af4
|
@ -171,6 +171,7 @@ struct RULES {
|
||||||
uint16_t mems_event = 0; // Bitmask supporting MAX_RULE_MEMS bits
|
uint16_t mems_event = 0; // Bitmask supporting MAX_RULE_MEMS bits
|
||||||
bool teleperiod = false;
|
bool teleperiod = false;
|
||||||
bool busy = false;
|
bool busy = false;
|
||||||
|
bool no_execute = false; // Don't actually execute rule commands
|
||||||
|
|
||||||
char event_data[100];
|
char event_data[100];
|
||||||
} Rules;
|
} Rules;
|
||||||
|
@ -708,6 +709,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (RulesRuleMatch(rule_set, event, event_trigger, stop_all_rules)) {
|
if (RulesRuleMatch(rule_set, event, event_trigger, stop_all_rules)) {
|
||||||
|
if (Rules.no_execute) return true;
|
||||||
if (plen == plen2) { stop_all_rules = true; } // If BREAK was used on a triggered rule, Stop execution of this rule set
|
if (plen == plen2) { stop_all_rules = true; } // If BREAK was used on a triggered rule, Stop execution of this rule set
|
||||||
commands.trim();
|
commands.trim();
|
||||||
String ucommand = commands;
|
String ucommand = commands;
|
||||||
|
|
|
@ -767,10 +767,19 @@ bool Xdrv35(uint8_t function)
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
}
|
}
|
||||||
|
|
||||||
// If hold time has arrived, handle it.
|
// If hold time has arrived and a rule is enabled that handles the button hold, handle it.
|
||||||
else if (button_hold_time[button_index] <= now) {
|
else if (button_hold_time[button_index] <= now) {
|
||||||
|
#ifdef USE_RULES
|
||||||
|
sprintf(TasmotaGlobal.mqtt_data, PSTR("{\"Button%u\":{\"State\":3}}"), button_index + 1);
|
||||||
|
Rules.no_execute = true;
|
||||||
|
if (!XdrvRulesProcess()) {
|
||||||
|
#endif // USE_RULES
|
||||||
PWMDimmerHandleButton(button_index, true);
|
PWMDimmerHandleButton(button_index, true);
|
||||||
button_held[button_index] = true;
|
button_held[button_index] = true;
|
||||||
|
#ifdef USE_RULES
|
||||||
|
}
|
||||||
|
Rules.no_execute = false;
|
||||||
|
#endif // USE_RULES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue