diff --git a/src/components/chart/state-history-chart-line.ts b/src/components/chart/state-history-chart-line.ts index 3474c1eb5b..46243893a3 100644 --- a/src/components/chart/state-history-chart-line.ts +++ b/src/components/chart/state-history-chart-line.ts @@ -137,12 +137,16 @@ export class StateHistoryChartLine extends LitElement { `${context.dataset.label}: ${formatNumber( context.parsed.y, this.hass.locale, - getNumberFormatOptions( - this.hass.states[this.data[context.datasetIndex].entity_id], - this.hass.entities[ - this.data[context.datasetIndex].entity_id - ] - ) + this.data[context.datasetIndex]?.entity_id + ? getNumberFormatOptions( + this.hass.states[ + this.data[context.datasetIndex].entity_id + ], + this.hass.entities[ + this.data[context.datasetIndex].entity_id + ] + ) + : undefined )} ${this.unit}`, }, },