Get attributes from first state when using minimal responses (#12732)

This commit is contained in:
J. Nick Koston 2022-05-19 22:56:11 -05:00 committed by GitHub
parent 5b7b0ea326
commit 1f105b6c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -272,7 +272,7 @@ const processTimelineEntity = (
states: EntityHistoryState[]
): TimelineEntity => {
const data: TimelineState[] = [];
const last: EntityHistoryState = states[states.length - 1];
const first: EntityHistoryState = states[0];
for (const state of states) {
if (data.length > 0 && state.s === data[data.length - 1].state) {
continue;
@ -282,7 +282,7 @@ const processTimelineEntity = (
localize,
language,
entityId,
state.a || last.a,
state.a || first.a,
state.s
),
state: state.s,
@ -307,7 +307,7 @@ const processLineChartEntities = (
Object.keys(entities).forEach((entityId) => {
const states = entities[entityId];
const last: EntityHistoryState = states[states.length - 1];
const first: EntityHistoryState = states[0];
const domain = computeDomain(entityId);
const processedStates: LineChartState[] = [];
@ -352,7 +352,7 @@ const processLineChartEntities = (
data.push({
domain,
name: computeStateNameFromEntityAttributes(entityId, last.a),
name: computeStateNameFromEntityAttributes(entityId, first.a),
entity_id: entityId,
states: processedStates,
});