fix: simplify countdown action to plain Turn ON / Turn OFF, no auto-reverse
This commit is contained in:
@@ -401,8 +401,8 @@
|
||||
<div class="form-group">
|
||||
<label>Action when timer fires</label>
|
||||
<select id="dwm-countdown-action">
|
||||
<option value="1">Turn ON (then auto-OFF after duration)</option>
|
||||
<option value="0">Turn OFF (then auto-ON after duration)</option>
|
||||
<option value="1">Turn ON</option>
|
||||
<option value="0">Turn OFF</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -196,7 +196,7 @@ function dwmRuleSummary(r) {
|
||||
}
|
||||
if (r.type === 'Countdown') {
|
||||
const mins = r.countdownTime ? Math.round(r.countdownTime / 60) : null;
|
||||
const action = r.countdownAction === 0 ? 'OFF → auto-ON' : 'ON → auto-OFF';
|
||||
const action = r.countdownAction === 0 ? 'Turn OFF' : 'Turn ON';
|
||||
return mins ? `⏱ ${mins} min · ${action}` : '—';
|
||||
}
|
||||
const days = dayLabel(r.days);
|
||||
|
||||
@@ -219,20 +219,12 @@ class DwmScheduler {
|
||||
if (windowStart < 0 || !(rule.windowDays?.length)) continue;
|
||||
|
||||
const countdownAction = Number(rule.countdownAction ?? 1);
|
||||
const countdownEnd = countdownAction === 1 ? 0 : 1; // opposite of start
|
||||
const crossesMidnight = windowEnd >= 0 && windowEnd < windowStart;
|
||||
for (const dayId of rule.windowDays) {
|
||||
for (const td of (rule.targetDevices ?? [])) {
|
||||
if (!td.host || !td.port) continue;
|
||||
schedule.push({ ruleId: rule.id, ruleName: rule.name,
|
||||
targetHost: td.host, targetPort: td.port,
|
||||
dayId: Number(dayId), targetSecs: windowStart, action: countdownAction });
|
||||
if (windowEnd >= 0) {
|
||||
const offDayId = crossesMidnight ? (Number(dayId) % 7) + 1 : Number(dayId);
|
||||
schedule.push({ ruleId: rule.id + '-wend', ruleName: rule.name,
|
||||
targetHost: td.host, targetPort: td.port,
|
||||
dayId: offDayId, targetSecs: windowEnd, action: countdownEnd });
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user