Martin-Laclaustra/CronAlarms

Trigger alarm only next day after restart

Closed this issue · 1 comments

For example, I must turn on a led at 08am and turn it off at 04pm.
// ...
Cron.create("0 0 16 * * *", { printLocalTime(); }, false);
Cron.create("0 0 8 * * *", { printLocalTime(); }, false);
// ...loop
Cron.delay();
// ...
But I saw that when restarting esp, alarms are triggered. How to work this to fire the next day? Since these times have passed.

Is this good practice?

bool alarm1Enabled = false;

Cron.create("0 0 8 * * *", {
if (alarm1Enabled) {
led.turnOn();
return;
}
alarm1Enabled = true;
}, false);

It's for my aquarium, it can't light up out of hours.