Merge remote-tracking branch 'origin/streaming_history_hui-graph-header-footer_maps' into remove_legacy_history_calls

This commit is contained in:
J. Nick Koston 2023-01-21 17:54:42 -10:00
commit 73b49642f8

View File

@ -330,15 +330,19 @@ class HuiMapCard extends LitElement implements LovelaceCard {
const paths: HaMapPaths[] = [];
Object.keys(history).forEach((entityId) => {
for (const entityId of Object.keys(history)) {
const entityStates = history[entityId];
if (entityStates?.length > 1) {
if (!entityStates?.length) {
continue;
}
// filter location data from states and remove all invalid locations
const points = entityStates.reduce(
(accumulator: HaMapPathPoint[], entityState) => {
const points: HaMapPathPoint[] = [];
for (const entityState of entityStates) {
const latitude = entityState.a.latitude;
const longitude = entityState.a.longitude;
if (latitude && longitude) {
if (!latitude || !longitude) {
continue;
}
const p = {} as HaMapPathPoint;
p.point = [latitude, longitude] as LatLngTuple;
const t = new Date(entityState.lu * 1000);
@ -351,20 +355,14 @@ class HuiMapCard extends LitElement implements LovelaceCard {
} else {
p.tooltip = formatTimeWeekday(t, this.hass.locale);
}
accumulator.push(p);
points.push(p);
}
return accumulator;
},
[]
) as HaMapPathPoint[];
paths.push({
points,
color: this._getColor(entityId),
gradualOpacity: 0.8,
});
}
});
return paths;
}
);