Skip to content

Commit

Permalink
insure ruletimers always stops at 0
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudor committed Jan 2, 2021
1 parent ca09594 commit 5bb682b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tasmota/xdrv_10_rules.ino
Original file line number Diff line number Diff line change
Expand Up @@ -974,20 +974,21 @@ void RulesEvery100ms(void)

void RulesEverySecond(void)
{
char json_event[120];
if (Settings.rule_enabled && !Rules.busy) { // Any rule enabled
char json_event[120];

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;
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Time\":{\"Minute\":%d}}"), MinutesPastMidnight());
RulesProcessEvent(json_event);
}
}
for (uint32_t i = 0; i < MAX_RULE_TIMERS; i++) {
if (Rules.timer[i] != 0L) { // Timer active?
if (TimeReached(Rules.timer[i])) { // Timer finished?
Rules.timer[i] = 0L; // Turn off this timer
}
for (uint32_t i = 0; i < MAX_RULE_TIMERS; i++) {
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
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Rules\":{\"Timer\":%d}}"), i +1);
RulesProcessEvent(json_event);
}
Expand Down

0 comments on commit 5bb682b

Please sign in to comment.