mirror of https://github.com/arendst/Tasmota.git
Berry always enable rules
This commit is contained in:
parent
7e0646b7fc
commit
77ca774b95
|
@ -130,6 +130,13 @@ const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<=$>$<$|$!$^";
|
||||||
#define IF_BLOCK_ENDIF 3
|
#define IF_BLOCK_ENDIF 3
|
||||||
#endif // USE_EXPRESSION
|
#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
|
const char kRulesCommands[] PROGMEM = "|" // No prefix
|
||||||
D_CMND_RULE "|" D_CMND_RULETIMER "|" D_CMND_EVENT "|" D_CMND_VAR "|" D_CMND_MEM "|"
|
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
|
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)
|
void RulesEvery50ms(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_BERRY
|
if ((Settings->rule_enabled || BERRY_RULES) && !Rules.busy) { // Any rule enabled
|
||||||
if (!Rules.busy) { // Emitting Rules events is always enabled with Berry
|
|
||||||
#else
|
|
||||||
if (Settings->rule_enabled && !Rules.busy) { // Any rule enabled
|
|
||||||
#endif
|
|
||||||
char json_event[120];
|
char json_event[120];
|
||||||
|
|
||||||
if (-1 == Rules.new_power) { Rules.new_power = TasmotaGlobal.power; }
|
if (-1 == Rules.new_power) { Rules.new_power = TasmotaGlobal.power; }
|
||||||
|
@ -1054,8 +1057,7 @@ void RulesEvery50ms(void)
|
||||||
|
|
||||||
void RulesEvery100ms(void) {
|
void RulesEvery100ms(void) {
|
||||||
static uint8_t xsns_index = 0;
|
static uint8_t xsns_index = 0;
|
||||||
|
if ((Settings->rule_enabled || BERRY_RULES) && !Rules.busy && (TasmotaGlobal.uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811)
|
||||||
if (Settings->rule_enabled && !Rules.busy && (TasmotaGlobal.uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811)
|
|
||||||
ResponseClear();
|
ResponseClear();
|
||||||
int tele_period_save = TasmotaGlobal.tele_period;
|
int tele_period_save = TasmotaGlobal.tele_period;
|
||||||
TasmotaGlobal.tele_period = 2; // Do not allow HA updates during next function call
|
TasmotaGlobal.tele_period = 2; // Do not allow HA updates during next function call
|
||||||
|
@ -1072,7 +1074,7 @@ void RulesEvery100ms(void) {
|
||||||
void RulesEverySecond(void)
|
void RulesEverySecond(void)
|
||||||
{
|
{
|
||||||
char json_event[120];
|
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 (RtcTime.valid) {
|
||||||
if ((TasmotaGlobal.uptime > 60) && (RtcTime.minute != Rules.last_minute)) { // Execute from one minute after restart every minute only once
|
if ((TasmotaGlobal.uptime > 60) && (RtcTime.minute != Rules.last_minute)) { // Execute from one minute after restart every minute only once
|
||||||
Rules.last_minute = RtcTime.minute;
|
Rules.last_minute = RtcTime.minute;
|
||||||
|
@ -1085,7 +1087,7 @@ void RulesEverySecond(void)
|
||||||
if (Rules.timer[i] != 0L) { // Timer active?
|
if (Rules.timer[i] != 0L) { // Timer active?
|
||||||
if (TimeReached(Rules.timer[i])) { // Timer finished?
|
if (TimeReached(Rules.timer[i])) { // Timer finished?
|
||||||
Rules.timer[i] = 0L; // Turn off this timer
|
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);
|
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Rules\":{\"Timer\":%d}}"), i +1);
|
||||||
RulesProcessEvent(json_event);
|
RulesProcessEvent(json_event);
|
||||||
}
|
}
|
||||||
|
@ -1096,7 +1098,7 @@ void RulesEverySecond(void)
|
||||||
|
|
||||||
void RulesSaveBeforeRestart(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];
|
char json_event[32];
|
||||||
|
|
||||||
strncpy_P(json_event, PSTR("{\"System\":{\"Save\":1}}"), sizeof(json_event));
|
strncpy_P(json_event, PSTR("{\"System\":{\"Save\":1}}"), sizeof(json_event));
|
||||||
|
|
Loading…
Reference in New Issue