mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Add translations for the developer tools statistic issues (#18646)
This commit is contained in:
parent
3addfc3548
commit
fb95de1f73
@ -27,6 +27,7 @@ import { HomeAssistant } from "../../../types";
|
||||
import { showStatisticsAdjustSumDialog } from "./show-dialog-statistics-adjust-sum";
|
||||
import { showFixStatisticsUnitsChangedDialog } from "./show-dialog-statistics-fix-units-changed";
|
||||
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
||||
import { documentationUrl } from "../../../util/documentation-url";
|
||||
|
||||
const FIX_ISSUES_ORDER = {
|
||||
no_state: 0,
|
||||
@ -266,13 +267,16 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
|
||||
switch (issue.type) {
|
||||
case "no_state":
|
||||
showConfirmationDialog(this, {
|
||||
title: "Entity has no state",
|
||||
text: html`This entity has no state at the moment, if this is an
|
||||
orphaned entity, you may want to remove the long term statistics of
|
||||
it from your database.<br /><br />Do you want to permanently remove
|
||||
the long term statistics of ${issue.data.statistic_id} from your
|
||||
database?`,
|
||||
confirmText: this.hass.localize("ui.common.remove"),
|
||||
title: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.no_state.title"
|
||||
),
|
||||
text: html`${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.no_state.info_text_1"
|
||||
)}<br /><br />${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.no_state.info_text_2",
|
||||
{ statistic_id: issue.data.statistic_id }
|
||||
)}`,
|
||||
confirmText: this.hass.localize("ui.common.delete"),
|
||||
confirm: async () => {
|
||||
await clearStatistics(this.hass, [issue.data.statistic_id]);
|
||||
this._validateStatistics();
|
||||
@ -281,60 +285,96 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
|
||||
break;
|
||||
case "entity_not_recorded":
|
||||
showAlertDialog(this, {
|
||||
title: "Entity not recorded",
|
||||
text: html`State changes of this entity are not recorded, therefore,
|
||||
we cannot track long term statistics for it. <br /><br />You
|
||||
probably excluded this entity, or have just included some
|
||||
entities.<br /><br />See the
|
||||
title: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.title"
|
||||
),
|
||||
text: html`${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_1"
|
||||
)}<br /><br />${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_2"
|
||||
)}<br /><br />
|
||||
<a
|
||||
href="https://www.home-assistant.io/integrations/recorder/#configure-filter"
|
||||
href=${documentationUrl(
|
||||
this.hass,
|
||||
"/integrations/recorder/#configure-filter"
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
recorder documentation</a
|
||||
>
|
||||
for more information.`,
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_3_link"
|
||||
)}</a
|
||||
>`,
|
||||
});
|
||||
break;
|
||||
case "entity_no_longer_recorded":
|
||||
showAlertDialog(this, {
|
||||
title: "Entity no longer recorded",
|
||||
text: html`We have generated statistics for this entity in the past,
|
||||
but state changes of this entity are no longer recorded, therefore,
|
||||
we cannot track long term statistics for it anymore. <br /><br />You
|
||||
probably excluded this entity, or have just included some
|
||||
entities.<br /><br />See the
|
||||
title: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.title"
|
||||
),
|
||||
text: html`${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.info_text_1"
|
||||
)}
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.info_text_2"
|
||||
)}
|
||||
<a
|
||||
href="https://www.home-assistant.io/integrations/recorder/#configure-filter"
|
||||
href=${documentationUrl(
|
||||
this.hass,
|
||||
"/integrations/recorder/#configure-filter"
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
recorder documentation</a
|
||||
>
|
||||
for more information.`,
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.info_text_3_link"
|
||||
)}</a
|
||||
>`,
|
||||
});
|
||||
break;
|
||||
case "unsupported_state_class":
|
||||
showConfirmationDialog(this, {
|
||||
title: "Unsupported state class",
|
||||
text: html`The state class of this entity, ${issue.data.state_class}
|
||||
is not supported. <br />Statistics cannot be generated until this
|
||||
entity has a supported state class.<br /><br />If this state class
|
||||
was provided by an integration, this is a bug. Please report an
|
||||
issue.<br /><br />If you have set this state class yourself, please
|
||||
correct it. The different state classes and when to use which can be
|
||||
found in the
|
||||
<a
|
||||
href="https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
developer documentation</a
|
||||
>. If the state class has permanently changed, you may want to
|
||||
remove the long term statistics of it from your database.<br /><br />Do
|
||||
you want to permanently remove the long term statistics of
|
||||
${issue.data.statistic_id} from your database?`,
|
||||
confirmText: this.hass.localize("ui.common.remove"),
|
||||
title: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.title"
|
||||
),
|
||||
text: html`${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_1",
|
||||
{ state_class: issue.data.state_class }
|
||||
)}<br /><br />
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_2"
|
||||
)}
|
||||
<ul>
|
||||
<li>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_3"
|
||||
)}
|
||||
</li>
|
||||
<li>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_4"
|
||||
)}
|
||||
<a
|
||||
href="https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_4_link"
|
||||
)}</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_5"
|
||||
)}
|
||||
</li>
|
||||
</ul>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_6",
|
||||
{ statistic_id: issue.data.statistic_id }
|
||||
)}`,
|
||||
confirmText: this.hass.localize("ui.common.delete"),
|
||||
confirm: async () => {
|
||||
await clearStatistics(this.hass, [issue.data.statistic_id]);
|
||||
this._validateStatistics();
|
||||
@ -351,8 +391,12 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
|
||||
break;
|
||||
default:
|
||||
showAlertDialog(this, {
|
||||
title: "Fix issue",
|
||||
text: "Fixing this issue is not supported yet.",
|
||||
title: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.no_support.title"
|
||||
),
|
||||
text: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.no_support.info_text_1"
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -34,8 +34,6 @@ import { HomeAssistant } from "../../../types";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import type { DialogStatisticsAdjustSumParams } from "./show-dialog-statistics-adjust-sum";
|
||||
|
||||
/* eslint-disable lit/no-template-arrow */
|
||||
|
||||
@customElement("dialog-statistics-adjust-sum")
|
||||
export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
@ -111,7 +109,9 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
scrimClickAction
|
||||
escapeKeyAction
|
||||
@closed=${this.closeDialog}
|
||||
heading="Adjust a statistic"
|
||||
.heading=${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.title"
|
||||
)}
|
||||
>
|
||||
${content}
|
||||
</ha-dialog>
|
||||
@ -133,7 +133,11 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
if (!this._stats5min || !this._statsHour) {
|
||||
stats = html`<ha-circular-progress active></ha-circular-progress>`;
|
||||
} else if (this._statsHour.length < 1 && this._stats5min.length < 1) {
|
||||
stats = html`<p>No statistics found for this period.</p>`;
|
||||
stats = html`<p>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.no_statistics_found"
|
||||
)}
|
||||
</p>`;
|
||||
} else {
|
||||
const data =
|
||||
this._stats5min.length >= 1 ? this._stats5min : this._statsHour;
|
||||
@ -150,11 +154,8 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
<mwc-list-item
|
||||
twoline
|
||||
hasMeta
|
||||
@click=${() => {
|
||||
this._chosenStat = stat;
|
||||
this._origAmount = growth;
|
||||
this._amount = growth;
|
||||
}}
|
||||
.stat=${stat}
|
||||
@click=${this._setChosenStatistic}
|
||||
>
|
||||
<span>${growth} ${unit}</span>
|
||||
<span slot="secondary">
|
||||
@ -173,15 +174,22 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
|
||||
return html`
|
||||
<div class="text-content">
|
||||
Sometimes the statistics end up being incorrect for a specific point in
|
||||
time. This can mess up your beautiful graphs! Select a time below to
|
||||
find the bad moment and adjust the data.
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.info_text_1"
|
||||
)}
|
||||
</div>
|
||||
<div class="text-content">
|
||||
<b>Statistic:</b> ${this._params!.statistic.statistic_id}
|
||||
<b
|
||||
>${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic"
|
||||
)}</b
|
||||
>
|
||||
${this._params!.statistic.statistic_id}
|
||||
</div>
|
||||
<ha-selector-datetime
|
||||
label="Pick a time"
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.pick_a_time"
|
||||
)}
|
||||
.hass=${this.hass}
|
||||
.selector=${this._dateTimeSelector}
|
||||
.value=${this._moment}
|
||||
@ -196,6 +204,19 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _clearChosenStatistic() {
|
||||
this._chosenStat = undefined;
|
||||
}
|
||||
|
||||
private _setChosenStatistic(ev) {
|
||||
const stat = ev.currentTarget.stat;
|
||||
const growth = Math.round(stat.change! * 100) / 100;
|
||||
|
||||
this._chosenStat = stat;
|
||||
this._origAmount = growth;
|
||||
this._amount = growth;
|
||||
}
|
||||
|
||||
private _dateTimeSelectorChanged(ev) {
|
||||
this._moment = ev.detail.value;
|
||||
this._fetchStats();
|
||||
@ -209,11 +230,20 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
);
|
||||
return html`
|
||||
<div class="text-content">
|
||||
<b>Statistic:</b> ${this._params!.statistic.statistic_id}
|
||||
<b
|
||||
>${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic"
|
||||
)}</b
|
||||
>
|
||||
${this._params!.statistic.statistic_id}
|
||||
</div>
|
||||
|
||||
<div class="table-row">
|
||||
<span>Start</span>
|
||||
<span
|
||||
>${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.start"
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
>${formatDateTime(
|
||||
new Date(this._chosenStat!.start),
|
||||
@ -224,7 +254,11 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
</div>
|
||||
|
||||
<div class="table-row">
|
||||
<span>End</span>
|
||||
<span
|
||||
>${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.end"
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
>${formatDateTime(
|
||||
new Date(this._chosenStat!.end),
|
||||
@ -235,35 +269,37 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
</div>
|
||||
|
||||
<ha-selector-number
|
||||
label="New Value"
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.new_value"
|
||||
)}
|
||||
.hass=${this.hass}
|
||||
.selector=${this._amountSelector(unit || undefined)}
|
||||
.value=${this._amount}
|
||||
.disabled=${this._busy}
|
||||
@value-changed=${(ev) => {
|
||||
this._amount = ev.detail.value;
|
||||
}}
|
||||
@value-changed=${this._amountChanged}
|
||||
></ha-selector-number>
|
||||
|
||||
<mwc-button
|
||||
slot="primaryAction"
|
||||
label="Adjust"
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.adjust"
|
||||
)}
|
||||
.disabled=${this._busy}
|
||||
@click=${() => {
|
||||
this._fixIssue();
|
||||
}}
|
||||
@click=${this._fixIssue}
|
||||
></mwc-button>
|
||||
<mwc-button
|
||||
slot="secondaryAction"
|
||||
.label=${this.hass.localize("ui.common.back")}
|
||||
.disabled=${this._busy}
|
||||
@click=${() => {
|
||||
this._chosenStat = undefined;
|
||||
}}
|
||||
@click=${this._clearChosenStatistic}
|
||||
></mwc-button>
|
||||
`;
|
||||
}
|
||||
|
||||
private _amountChanged(ev) {
|
||||
this._amount = ev.detail.value;
|
||||
}
|
||||
|
||||
private async _fetchStats(): Promise<void> {
|
||||
this._stats5min = undefined;
|
||||
this._statsHour = undefined;
|
||||
@ -331,12 +367,17 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
} catch (err: any) {
|
||||
this._busy = false;
|
||||
showAlertDialog(this, {
|
||||
text: `Error adjusting sum: ${err.message || err}`,
|
||||
text: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.error_sum_adjusted",
|
||||
{ message: err.message || err }
|
||||
),
|
||||
});
|
||||
return;
|
||||
}
|
||||
showToast(this, {
|
||||
message: "Statistic sum adjusted",
|
||||
message: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.sum_adjusted"
|
||||
),
|
||||
});
|
||||
this.closeDialog();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
if (!this._params) {
|
||||
return nothing;
|
||||
}
|
||||
/* eslint-disable lit/quoted-expressions */
|
||||
|
||||
return html`
|
||||
<ha-dialog
|
||||
open
|
||||
@ -46,17 +46,26 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
)}
|
||||
>
|
||||
<p>
|
||||
The unit of this entity changed to
|
||||
'${this._params.issue.data.state_unit}' which can't be converted to
|
||||
the previously stored unit,
|
||||
'${this._params.issue.data.metadata_unit}'.
|
||||
<br />If the historic statistic values have a wrong unit, you can
|
||||
update the units of the old values. The values will not be updated.<br />Otherwise
|
||||
you can choose to delete all historic statistic values, and start
|
||||
over.
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_1",
|
||||
{
|
||||
current_unit: this._params.issue.data.state_unit,
|
||||
previous_unit: this._params.issue.data.metadata_unit,
|
||||
}
|
||||
)}<br />
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_2"
|
||||
)}<br />
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_3"
|
||||
)}
|
||||
</p>
|
||||
|
||||
<h3>How do you want to fix this issue?</h3>
|
||||
<h3>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.how_to_fix"
|
||||
)}
|
||||
</h3>
|
||||
<ha-formfield
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.update",
|
||||
@ -94,7 +103,6 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
</mwc-button>
|
||||
</ha-dialog>
|
||||
`;
|
||||
/* eslint-enable lit/quoted-expressions */
|
||||
}
|
||||
|
||||
private _handleActionChanged(ev): void {
|
||||
|
@ -5828,10 +5828,58 @@
|
||||
},
|
||||
"fix_issue": {
|
||||
"fix": "Fix issue",
|
||||
"no_support": {
|
||||
"title": "Fix issue",
|
||||
"info_text_1": "Fixing this issue is not supported yet."
|
||||
},
|
||||
"no_state": {
|
||||
"title": "Entity has no state",
|
||||
"info_text_1": "This entity has no state at the moment, if this is an orphaned entity, you may want to delete the long term statistics of it from your database.",
|
||||
"info_text_2": "Do you want to permanently delete the long term statistics of {statistic_id} from your database?"
|
||||
},
|
||||
"entity_not_recorded": {
|
||||
"title": "Entity not recorded",
|
||||
"info_text_1": "State changes of this entity are not recorded, therefore, we cannot track long term statistics for it.",
|
||||
"info_text_2": "You probably excluded this entity, or have just included some entities.",
|
||||
"info_text_3_link": "See the recorder documentation for more information."
|
||||
},
|
||||
"entity_no_longer_recorded": {
|
||||
"title": "Entity no longer recorded",
|
||||
"info_text_1": "We have generated statistics for this entity in the past, but state changes of this entity are no longer recorded, therefore, we cannot track long term statistics for it anymore.",
|
||||
"info_text_2": "You probably excluded this entity, or have just included some entities.",
|
||||
"info_text_3_link": "See the recorder documentation for more information."
|
||||
},
|
||||
"unsupported_state_class": {
|
||||
"title": "Unsupported state class",
|
||||
"info_text_1": "The state class of this entity, {state_class} is not supported.",
|
||||
"info_text_2": "Statistics cannot be generated until this entity has a supported state class.",
|
||||
"info_text_3": "If this state class was provided by an integration, this is a bug. Please report an issue.",
|
||||
"info_text_4": "If you have set this state class yourself, please correct it.",
|
||||
"info_text_4_link": "The different state classes and when to use which can be found in the developer documentation.",
|
||||
"info_text_5": "If the state class has permanently changed, you may want to delete the long term statistics of it from your database.",
|
||||
"info_text_6": "Do you want to permanently delete the long term statistics of {statistic_id} from your database?"
|
||||
},
|
||||
"units_changed": {
|
||||
"title": "The unit of this entity changed",
|
||||
"update": "Update the unit of the historic statistic values from ''{metadata_unit}'' to ''{state_unit}'', without converting.",
|
||||
"clear": "Delete all old statistic data for this entity"
|
||||
"clear": "Delete all old statistic data for this entity",
|
||||
"how_to_fix": "How do you want to fix this issue?",
|
||||
"info_text_1": "The unit of this entity changed to ''{current_unit}'' which can't be converted to the previously stored unit, ''{previous_unit}''.",
|
||||
"info_text_2": "If the historic statistic values have a wrong unit, you can update the units of the old values. The values will not be updated.",
|
||||
"info_text_3": "Otherwise you can choose to delete all historic statistic values, and start over."
|
||||
},
|
||||
"adjust_sum": {
|
||||
"title": "Adjust a statistic",
|
||||
"no_statistics_found": "No statistics found for this period.",
|
||||
"info_text_1": "Sometimes the statistics end up being incorrect for a specific point in time. This can mess up your beautiful graphs! Select a time below to find the bad moment and adjust the data.",
|
||||
"pick_a_time": "Pick a time",
|
||||
"statistic": "Statistic:",
|
||||
"start": "Start",
|
||||
"end": "End",
|
||||
"new_value": "New value",
|
||||
"adjust": "Adjust",
|
||||
"sum_adjusted": "Statistic sum adjusted",
|
||||
"error_sum_adjusted": "Error adjusting sum: {message}"
|
||||
}
|
||||
},
|
||||
"adjust_sum": "Adjust sum",
|
||||
|
Loading…
x
Reference in New Issue
Block a user