1
0
Fork 0

[sleeplogalarm] Correct filter for last alarm

master
storm64 2022-11-23 18:11:42 +01:00
parent 7ef5152c17
commit ad7161cc93
3 changed files with 10 additions and 9 deletions

View File

@ -1,2 +1,3 @@
0.01: New App!
0.02: Add "from Consec."-setting
0.02: Add "from Consec."-setting
0.03: Correct how to ignore last triggered alarm

View File

@ -8,13 +8,13 @@ function getNextAlarm(allAlarms, fo, withId) {
return a;
});
// return next active alarms in range, filter for
// active, not timer, not own alarm,
// after from, before to, includes msg
// not lastTime, not lastDay
// active && not timer && not own alarm &&
// after from && before to && includes msg &&
// lastDate not today || after lastTime
return allAlarms.filter(
a => a.on && !a.timer && a.id !== "sleeplog" &&
a.t >= fo.from && a.t < fo.to && (!fo.msg || a.msg.includes(fo.msg)) &&
fo.lastTime !== a.t && fo.lastDay !== a.last
fo.lastDate !== new Date().getDate() || a.t > fo.lastTime
).map(a => { // add time to alarm
a.tTo = sched.getTimeToAlarm(a);
return a;
@ -58,7 +58,7 @@ exports = {
to: settings.filter_to * 36E5,
msg: settings.filter_msg,
lastTime: settings.lastTime,
lastDay: settings.lastDay
lastDate: settings.lastDate
}).t;
// abort if no alarm time could be found inside range
@ -95,7 +95,7 @@ exports = {
to: settings.filter_to * 36E5,
msg: settings.filter_msg,
lastTime: settings.lastTime,
lastDay: settings.lastDay
lastDate: settings.lastDate
}, settings.disableOnAlarm);
// return if no alarm is found
@ -133,7 +133,7 @@ exports = {
// save time of alarm and this day to prevent triggering for the same alarm again
settings.lastTime = alarm.t;
settings.lastDay = now.getDay();
settings.lastDate = now.getDay();
require("Storage").writeJSON("sleeplogalarm.settings.json", settings);
// write changes

View File

@ -2,7 +2,7 @@
"id":"sleeplogalarm",
"name":"Sleep Log Alarm",
"shortName": "SleepLogAlarm",
"version": "0.02",
"version": "0.03",
"description": "Enhance your morning and let your alarms wake you up when you are in light sleep.",
"icon": "app.png",
"type": "widget",