Skip to content

Commit

Permalink
fix: Friendly name wouldn't display anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Apr 24, 2022
1 parent 8024ae8 commit ef38724
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Expand Up @@ -1326,6 +1326,7 @@ views:
header:
show: true
title: Test Stats
show_states: true
title_actions:
tap_action:
action: more-info
Expand All @@ -1343,3 +1344,4 @@ views:
statistics:
type: mean
period: 5minute
- entity: sensor.temperature
2 changes: 1 addition & 1 deletion src/apexcharts-card.ts
Expand Up @@ -215,7 +215,7 @@ class ChartsCard extends LitElement {
if (this._config?.experimental?.hidden_by_default) {
this._config.series_in_graph.forEach((serie, index) => {
if (serie.show.hidden_by_default) {
const name = computeName(index, this._config?.series_in_graph, this._hass?.states);
const name = computeName(index, this._config?.series_in_graph, this._entities);
this._apexChart?.hideSeries(name);
}
});
Expand Down
3 changes: 1 addition & 2 deletions src/utils.ts
Expand Up @@ -70,8 +70,7 @@ export function computeName(
if (entity) {
name = series[index].name || entity.attributes?.friendly_name || entity.entity_id || '';
} else if (entities) {
const serieEntity = series[index].entity;
name = series[index].name || entities[serieEntity]?.attributes?.friendly_name || serieEntity || '';
name = series[index].name || entities[index]?.attributes?.friendly_name || entities[index]?.entity_id || '';
}
return name + (series[index].show?.offset_in_name && series[index].offset ? ` (${series[index].offset})` : '');
}
Expand Down

0 comments on commit ef38724

Please sign in to comment.