From 77ca774b9556ff46969f2cf6d616f2199ffb2ec4 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 14 Feb 2022 12:51:29 +0100 Subject: [PATCH] Berry always enable rules --- tasmota/xdrv_10_rules.ino | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 5774ade6a..4fd45550e 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -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));