257 files

This commit is contained in:
Home Assistant Version Control
2026-10-02 16:06:24 +00:00
parent 7c55603942
commit c29f5cc088
258 changed files with 24621 additions and 3136 deletions
@@ -89,6 +89,12 @@ export function computeTrend(
return Math.sign(delta) === toward ? "approaching" : "easing";
}
/** Whole days for a due-date reading (days left, fractional): a date later
* today reads as today, one 30 hours away as 2 days. */
export function dueDaysOf(daysLeft: number): number {
return daysLeft > 0 ? Math.ceil(daysLeft) : Math.trunc(daysLeft) || 0;
}
export function renderTriggerProgress(row: TaskRow | MaintenanceTask, opts?: { trend?: TrendState | null; lang?: string }) {
const tc = row.trigger_config ?? null;
if (!tc) return nothing;
@@ -176,6 +182,14 @@ export function renderTriggerProgress(row: TaskRow | MaintenanceTask, opts?: { t
if (val == null) return nothing;
pct = Math.min(100, Math.max(0, (val / target) * 100));
label = `${formatNumber(val, opts?.lang, 1)}h / ${formatNumber(target, opts?.lang)}h`;
} else if (triggerType === "due_date") {
// The reading is the days left until the date the device reports: the
// bar fills over the last month before the lead time runs out.
const val = row.trigger_current_value ?? null;
if (val == null) return nothing;
const lead = tc.trigger_days_before ?? 0;
pct = val <= lead ? 100 : Math.max(0, 100 - ((val - lead) / 30) * 100);
label = formatDueDays(dueDaysOf(val), opts?.lang);
} else if (triggerType === "compound") {
const logic = tc.compound_logic || (tc as any).operator || "AND";
const condCount = tc.conditions?.length || 0;