diff --git a/src/panels/developer-tools/statistics/developer-tools-statistics.ts b/src/panels/developer-tools/statistics/developer-tools-statistics.ts index 7eb112a634..375ef0355e 100644 --- a/src/panels/developer-tools/statistics/developer-tools-statistics.ts +++ b/src/panels/developer-tools/statistics/developer-tools-statistics.ts @@ -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.

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" + )}

${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.

You - probably excluded this entity, or have just included some - entities.

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" + )}

${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_2" + )}

- recorder documentation - for more information.`, + ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_not_recorded.info_text_3_link" + )}`, }); 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.

You - probably excluded this entity, or have just included some - entities.

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" + )} - recorder documentation - for more information.`, + ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.entity_no_longer_recorded.info_text_3_link" + )}`, }); 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.
Statistics cannot be generated until this - entity has a supported state class.

If this state class - was provided by an integration, this is a bug. Please report an - issue.

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 - - developer documentation. If the state class has permanently changed, you may want to - remove the long term statistics of it from your database.

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 } + )}

+ ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.unsupported_state_class.info_text_2" + )} + + ${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" + ), }); } }; diff --git a/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts b/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts index b34769e44b..29dc7f2f94 100644 --- a/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts +++ b/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts @@ -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} @@ -133,7 +133,11 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement { if (!this._stats5min || !this._statsHour) { stats = html``; } else if (this._statsHour.length < 1 && this._stats5min.length < 1) { - stats = html`

No statistics found for this period.

`; + stats = html`

+ ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.no_statistics_found" + )} +

`; } else { const data = this._stats5min.length >= 1 ? this._stats5min : this._statsHour; @@ -150,11 +154,8 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement { { - this._chosenStat = stat; - this._origAmount = growth; - this._amount = growth; - }} + .stat=${stat} + @click=${this._setChosenStatistic} > ${growth} ${unit} @@ -173,15 +174,22 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement { return html`
- 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" + )}
- Statistic: ${this._params!.statistic.statistic_id} + ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic" + )} + ${this._params!.statistic.statistic_id}
- Statistic: ${this._params!.statistic.statistic_id} + ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic" + )} + ${this._params!.statistic.statistic_id}
- Start + ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.start" + )} ${formatDateTime( new Date(this._chosenStat!.start), @@ -224,7 +254,11 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
- End + ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.adjust_sum.end" + )} ${formatDateTime( new Date(this._chosenStat!.end), @@ -235,35 +269,37 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
{ - this._amount = ev.detail.value; - }} + @value-changed=${this._amountChanged} > { - this._fixIssue(); - }} + @click=${this._fixIssue} > { - this._chosenStat = undefined; - }} + @click=${this._clearChosenStatistic} > `; } + private _amountChanged(ev) { + this._amount = ev.detail.value; + } + private async _fetchStats(): Promise { 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(); } diff --git a/src/panels/developer-tools/statistics/dialog-statistics-fix-units-changed.ts b/src/panels/developer-tools/statistics/dialog-statistics-fix-units-changed.ts index 27e5fa7064..682fa58b2c 100644 --- a/src/panels/developer-tools/statistics/dialog-statistics-fix-units-changed.ts +++ b/src/panels/developer-tools/statistics/dialog-statistics-fix-units-changed.ts @@ -36,7 +36,7 @@ export class DialogStatisticsFixUnitsChanged extends LitElement { if (!this._params) { return nothing; } - /* eslint-disable lit/quoted-expressions */ + return html`

- 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}'. -
If the historic statistic values have a wrong unit, you can - update the units of the old values. The values will not be updated.
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, + } + )}
+ ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_2" + )}
+ ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.info_text_3" + )}

-

How do you want to fix this issue?

+

+ ${this.hass.localize( + "ui.panel.developer-tools.tabs.statistics.fix_issue.units_changed.how_to_fix" + )} +

`; - /* eslint-enable lit/quoted-expressions */ } private _handleActionChanged(ev): void { diff --git a/src/translations/en.json b/src/translations/en.json index 3131d30bfa..aad5c61d9d 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -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",