361 files
This commit is contained in:
@@ -16,6 +16,7 @@ import { t, formatDate, formatDueDays, formatNumber } from "../styles";
|
||||
import { px } from "./chart-utils";
|
||||
import { daysProgress } from "../helpers/interval";
|
||||
import { stampMs } from "../helpers/ha-time";
|
||||
import { primaryTriggerEntity } from "../helpers/trigger-entities";
|
||||
import type { MaintenanceTask, TaskRow, StatisticsPoint } from "../types";
|
||||
|
||||
const MINI_SPARKLINE_W = 60;
|
||||
@@ -36,7 +37,9 @@ export function computeTrend(
|
||||
miniStatsData: Map<string, StatisticsPoint[]>,
|
||||
): TrendState | null {
|
||||
const tc = row.trigger_config;
|
||||
if (!tc?.entity_id) return null;
|
||||
const entityId = primaryTriggerEntity(tc);
|
||||
// The battery fleet's row tells "N to replace", not one battery's curve.
|
||||
if (!tc || !entityId || row.battery_fleet_task) return null;
|
||||
let toward: 1 | -1;
|
||||
const type = tc.type || "threshold";
|
||||
if (type === "threshold") {
|
||||
@@ -48,7 +51,7 @@ export function computeTrend(
|
||||
} else {
|
||||
return null; // compound: conditions may point both ways
|
||||
}
|
||||
const statsPoints = miniStatsData.get(tc.entity_id) || [];
|
||||
const statsPoints = miniStatsData.get(entityId) || [];
|
||||
// Runtime and state_change accumulate SINCE the last completion — the
|
||||
// history's trigger_value is the count at the previous trigger, a point
|
||||
// from before the reset. Falling back to it read a freshly reset task
|
||||
@@ -235,8 +238,9 @@ export function renderMiniSparkline(
|
||||
miniStatsData: Map<string, StatisticsPoint[]>,
|
||||
lang: string,
|
||||
) {
|
||||
if (!row.trigger_config?.entity_id) return nothing;
|
||||
const entityId = row.trigger_config.entity_id;
|
||||
const entityId = primaryTriggerEntity(row.trigger_config);
|
||||
// The battery fleet's row tells "N to replace", not one battery's curve.
|
||||
if (!entityId || row.battery_fleet_task) return nothing;
|
||||
|
||||
// PRIMARY: HA recorder statistics (daily, last 14 days)
|
||||
const statsPoints = miniStatsData.get(entityId) || [];
|
||||
|
||||
Reference in New Issue
Block a user