Merge pull request #14850 from s-hadinger/berry_rule_tele

Berry always enable rules
This commit is contained in:
s-hadinger 2022-02-14 13:54:12 +01:00 committed by GitHub
commit 64aa9b69c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 10 deletions

View File

@ -130,6 +130,13 @@ const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<=$>$<$|$!$^";
#define IF_BLOCK_ENDIF 3
#endif // USE_EXPRESSION
// Define to indicate that rules are always enabled
#ifdef USE_BERRY
#define BERRY_RULES 1
#else
#define BERRY_RULES 0
#endif
const char kRulesCommands[] PROGMEM = "|" // No prefix
D_CMND_RULE "|" D_CMND_RULETIMER "|" D_CMND_EVENT "|" D_CMND_VAR "|" D_CMND_MEM "|"
D_CMND_ADD "|" D_CMND_SUB "|" D_CMND_MULT "|" D_CMND_SCALE "|" D_CMND_CALC_RESOLUTION
@ -898,11 +905,7 @@ void RulesInit(void)
void RulesEvery50ms(void)
{
#ifdef USE_BERRY
if (!Rules.busy) { // Emitting Rules events is always enabled with Berry
#else
if (Settings->rule_enabled && !Rules.busy) { // Any rule enabled
#endif
if ((Settings->rule_enabled || BERRY_RULES) && !Rules.busy) { // Any rule enabled
char json_event[120];
if (-1 == Rules.new_power) { Rules.new_power = TasmotaGlobal.power; }
@ -1054,8 +1057,7 @@ void RulesEvery50ms(void)
void RulesEvery100ms(void) {
static uint8_t xsns_index = 0;
if (Settings->rule_enabled && !Rules.busy && (TasmotaGlobal.uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811)
if ((Settings->rule_enabled || BERRY_RULES) && !Rules.busy && (TasmotaGlobal.uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811)
ResponseClear();
int tele_period_save = TasmotaGlobal.tele_period;
TasmotaGlobal.tele_period = 2; // Do not allow HA updates during next function call
@ -1072,7 +1074,7 @@ void RulesEvery100ms(void) {
void RulesEverySecond(void)
{
char json_event[120];
if (Settings->rule_enabled && !Rules.busy) { // Any rule enabled
if ((Settings->rule_enabled || BERRY_RULES) && !Rules.busy) { // Any rule enabled
if (RtcTime.valid) {
if ((TasmotaGlobal.uptime > 60) && (RtcTime.minute != Rules.last_minute)) { // Execute from one minute after restart every minute only once
Rules.last_minute = RtcTime.minute;
@ -1085,7 +1087,7 @@ void RulesEverySecond(void)
if (Rules.timer[i] != 0L) { // Timer active?
if (TimeReached(Rules.timer[i])) { // Timer finished?
Rules.timer[i] = 0L; // Turn off this timer
if (Settings->rule_enabled && !Rules.busy) { // Any rule enabled
if ((Settings->rule_enabled || BERRY_RULES) && !Rules.busy) { // Any rule enabled
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Rules\":{\"Timer\":%d}}"), i +1);
RulesProcessEvent(json_event);
}
@ -1096,7 +1098,7 @@ void RulesEverySecond(void)
void RulesSaveBeforeRestart(void)
{
if (Settings->rule_enabled && !Rules.busy) { // Any rule enabled
if ((Settings->rule_enabled || BERRY_RULES) && !Rules.busy) { // Any rule enabled
char json_event[32];
strncpy_P(json_event, PSTR("{\"System\":{\"Save\":1}}"), sizeof(json_event));