mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
don't use entity name as label in more info stats (#14213)
This commit is contained in:
parent
4c8e863c0e
commit
b3e2beac5a
@ -253,7 +253,7 @@ class StatisticsChart extends LitElement {
|
|||||||
const firstStat = stats[0];
|
const firstStat = stats[0];
|
||||||
const meta = statisticsMetaData?.[firstStat.statistic_id];
|
const meta = statisticsMetaData?.[firstStat.statistic_id];
|
||||||
let name = names[firstStat.statistic_id];
|
let name = names[firstStat.statistic_id];
|
||||||
if (!name) {
|
if (name === undefined) {
|
||||||
name = getStatisticLabel(this.hass, firstStat.statistic_id, meta);
|
name = getStatisticLabel(this.hass, firstStat.statistic_id, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,10 +324,14 @@ class StatisticsChart extends LitElement {
|
|||||||
const band = drawBands && (type === "min" || type === "max");
|
const band = drawBands && (type === "min" || type === "max");
|
||||||
statTypes.push(type);
|
statTypes.push(type);
|
||||||
statDataSets.push({
|
statDataSets.push({
|
||||||
label: `${name} (${this.hass.localize(
|
label: name
|
||||||
`ui.components.statistics_charts.statistic_types.${type}`
|
? `${name} (${this.hass.localize(
|
||||||
)})
|
`ui.components.statistics_charts.statistic_types.${type}`
|
||||||
`,
|
)})
|
||||||
|
`
|
||||||
|
: this.hass.localize(
|
||||||
|
`ui.components.statistics_charts.statistic_types.${type}`
|
||||||
|
),
|
||||||
fill: drawBands
|
fill: drawBands
|
||||||
? type === "min"
|
? type === "min"
|
||||||
? "+1"
|
? "+1"
|
||||||
|
@ -36,6 +36,8 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
|
|
||||||
private _showMoreHref = "";
|
private _showMoreHref = "";
|
||||||
|
|
||||||
|
private _statNames?: Record<string, string>;
|
||||||
|
|
||||||
private _throttleGetStateHistory = throttle(() => {
|
private _throttleGetStateHistory = throttle(() => {
|
||||||
this._getStateHistory();
|
this._getStateHistory();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
@ -62,6 +64,7 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
.isLoadingData=${!this._statistics}
|
.isLoadingData=${!this._statistics}
|
||||||
.statisticsData=${this._statistics}
|
.statisticsData=${this._statistics}
|
||||||
.statTypes=${statTypes}
|
.statTypes=${statTypes}
|
||||||
|
.names=${this._statNames}
|
||||||
></statistics-chart>`
|
></statistics-chart>`
|
||||||
: html`<state-history-charts
|
: html`<state-history-charts
|
||||||
up-to-now
|
up-to-now
|
||||||
@ -113,6 +116,7 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
computeDomain(this.entityId) === "sensor"
|
computeDomain(this.entityId) === "sensor"
|
||||||
) {
|
) {
|
||||||
const metadata = await getStatisticMetadata(this.hass, [this.entityId]);
|
const metadata = await getStatisticMetadata(this.hass, [this.entityId]);
|
||||||
|
this._statNames = { [this.entityId]: "" };
|
||||||
if (metadata.length) {
|
if (metadata.length) {
|
||||||
this._statistics = await fetchStatistics(
|
this._statistics = await fetchStatistics(
|
||||||
this.hass!,
|
this.hass!,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user