mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Preserve custom names in statistics graph when modifying entity list (#15695)
This commit is contained in:
parent
4d19e3ad63
commit
55edeb474e
@ -300,18 +300,26 @@ export class HuiStatisticsGraphCardEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _entitiesChanged(ev: CustomEvent): Promise<void> {
|
private async _entitiesChanged(ev: CustomEvent): Promise<void> {
|
||||||
const config = { ...this._config!, entities: ev.detail.value };
|
const newEntityIds = ev.detail.value;
|
||||||
|
|
||||||
|
// Save the EntityConfig objects from being replaced with strings
|
||||||
|
const newEntities = newEntityIds.map((newEnt) => {
|
||||||
|
const matchEntity = this._config!.entities.find(
|
||||||
|
(oldEnt) => typeof oldEnt !== "string" && oldEnt.entity === newEnt
|
||||||
|
);
|
||||||
|
return matchEntity ?? newEnt;
|
||||||
|
});
|
||||||
|
|
||||||
|
const config = { ...this._config!, entities: newEntities };
|
||||||
if (
|
if (
|
||||||
config.entities?.some((statistic_id) =>
|
newEntityIds?.some((statistic_id) => isExternalStatistic(statistic_id)) &&
|
||||||
isExternalStatistic(statistic_id)
|
|
||||||
) &&
|
|
||||||
config.period === "5minute"
|
config.period === "5minute"
|
||||||
) {
|
) {
|
||||||
delete config.period;
|
delete config.period;
|
||||||
}
|
}
|
||||||
const metadata =
|
const metadata =
|
||||||
config.stat_types || config.unit
|
config.stat_types || config.unit
|
||||||
? await getStatisticMetadata(this.hass!, config.entities)
|
? await getStatisticMetadata(this.hass!, newEntityIds)
|
||||||
: undefined;
|
: undefined;
|
||||||
if (config.stat_types && config.entities.length) {
|
if (config.stat_types && config.entities.length) {
|
||||||
config.stat_types = ensureArray(config.stat_types).filter((stat_type) =>
|
config.stat_types = ensureArray(config.stat_types).filter((stat_type) =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user