mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Use backend translations for energy validation (#15069)
This commit is contained in:
parent
663b6e0682
commit
1aa23d75b0
@ -186,8 +186,8 @@ export interface EnergyInfo {
|
||||
|
||||
export interface EnergyValidationIssue {
|
||||
type: string;
|
||||
identifier: string;
|
||||
value?: unknown;
|
||||
affected_entities: [string, unknown][];
|
||||
translation_placeholders: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface EnergyPreferencesValidation {
|
||||
@ -200,10 +200,12 @@ export const getEnergyInfo = (hass: HomeAssistant) =>
|
||||
type: "energy/info",
|
||||
});
|
||||
|
||||
export const getEnergyPreferenceValidation = (hass: HomeAssistant) =>
|
||||
hass.callWS<EnergyPreferencesValidation>({
|
||||
export const getEnergyPreferenceValidation = async (hass: HomeAssistant) => {
|
||||
await hass.loadBackendTranslation("issues", "energy");
|
||||
return hass.callWS<EnergyPreferencesValidation>({
|
||||
type: "energy/validate",
|
||||
});
|
||||
};
|
||||
|
||||
export const getEnergyPreferences = (hass: HomeAssistant) =>
|
||||
hass.callWS<EnergyPreferences>({
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { groupBy } from "../../../../common/util/group-by";
|
||||
import "../../../../components/ha-alert";
|
||||
import { EnergyValidationIssue } from "../../../../data/energy";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
@ -18,46 +17,33 @@ class EnergyValidationMessage extends LitElement {
|
||||
return html``;
|
||||
}
|
||||
|
||||
const grouped = groupBy(this.issues, (issue) => issue.type);
|
||||
|
||||
return Object.entries(grouped).map(
|
||||
([issueType, gIssues]) => html`
|
||||
<ha-alert
|
||||
alert-type="warning"
|
||||
.title=${
|
||||
this.hass.localize(
|
||||
`ui.panel.config.energy.validation.issues.${issueType}.title`
|
||||
) || issueType
|
||||
}
|
||||
>
|
||||
${this.hass.localize(
|
||||
`ui.panel.config.energy.validation.issues.${issueType}.description`,
|
||||
{ currency: this.hass.config.currency }
|
||||
return this.issues.map(
|
||||
(issue) => html`
|
||||
<ha-alert
|
||||
alert-type="warning"
|
||||
.title=${this.hass.localize(
|
||||
`component.energy.issues.${issue.type}.title`
|
||||
) || issue.type}
|
||||
>
|
||||
${this.hass.localize(
|
||||
`component.energy.issues.${issue.type}.description`,
|
||||
issue.translation_placeholders
|
||||
)}
|
||||
${issue.type === "recorder_untracked"
|
||||
? html`(<a
|
||||
href="https://www.home-assistant.io/integrations/recorder#configure-filter"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>${this.hass.localize("ui.panel.config.common.learn_more")}</a
|
||||
>)`
|
||||
: ""}
|
||||
<ul>
|
||||
${issue.affected_entities.map(
|
||||
([entity, value]) =>
|
||||
html`<li>${entity}${value ? html` (${value})` : ""}</li>`
|
||||
)}
|
||||
${
|
||||
issueType === "recorder_untracked"
|
||||
? html`(<a
|
||||
href="https://www.home-assistant.io/integrations/recorder#configure-filter"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.common.learn_more"
|
||||
)}</a
|
||||
>)`
|
||||
: ""
|
||||
}
|
||||
<ul>
|
||||
${gIssues.map(
|
||||
(issue) =>
|
||||
html`<li>
|
||||
${issue.identifier}${issue.value
|
||||
? html` (${issue.value})`
|
||||
: ""}
|
||||
</li>`
|
||||
)}
|
||||
</ul>
|
||||
</ha-alert>
|
||||
</div>
|
||||
</ul>
|
||||
</ha-alert>
|
||||
`
|
||||
);
|
||||
}
|
||||
|
@ -1634,66 +1634,6 @@
|
||||
"device_consumption_energy": "Device consumption energy (kWh)",
|
||||
"selected_stat_intro": "Select the entity that represents the device energy usage."
|
||||
}
|
||||
},
|
||||
"validation": {
|
||||
"issues": {
|
||||
"entity_not_defined": {
|
||||
"title": "Entity not defined",
|
||||
"description": "Check the integration or your configuration that provides:"
|
||||
},
|
||||
"recorder_untracked": {
|
||||
"title": "Entity not tracked",
|
||||
"description": "The recorder has been configured to exclude these configured entities:"
|
||||
},
|
||||
"entity_unavailable": {
|
||||
"title": "Entity unavailable",
|
||||
"description": "The state of these configured entities are currently not available:"
|
||||
},
|
||||
"entity_state_non_numeric": {
|
||||
"title": "Entity has non-numeric state",
|
||||
"description": "The following entities have a state that cannot be parsed as a number:"
|
||||
},
|
||||
"entity_negative_state": {
|
||||
"title": "Entity has a negative state",
|
||||
"description": "The following entities have a negative state while a positive state is expected:"
|
||||
},
|
||||
"entity_unexpected_unit_energy": {
|
||||
"title": "Unexpected unit of measurement",
|
||||
"description": "The following entities do not have the expected units of measurement 'Wh', 'kWh', 'MWh' or 'GJ':"
|
||||
},
|
||||
"entity_unexpected_unit_gas": {
|
||||
"title": "Unexpected unit of measurement",
|
||||
"description": "The following entities do not have the expected units of measurement 'Wh', 'kWh', 'MWh' or 'GJ' for an energy sensor or 'm³' or 'ft³' for a gas sensor:"
|
||||
},
|
||||
"entity_unexpected_unit_water": {
|
||||
"title": "Unexpected unit of measurement",
|
||||
"description": "The following entities do not have the expected units of measurement 'm³' or 'ft³' for a water sensor:"
|
||||
},
|
||||
"entity_unexpected_unit_energy_price": {
|
||||
"title": "Unexpected unit of measurement",
|
||||
"description": "The following entities do not have the expected units of measurement ''{currency}/kWh'', ''{currency}/Wh'', ''{currency}/MWh'' or ''{currency}/GJ'':"
|
||||
},
|
||||
"entity_unexpected_unit_gas_price": {
|
||||
"title": "Unexpected unit of measurement",
|
||||
"description": "The following entities do not have the expected units of measurement ''{currency}/kWh'', ''{currency}/Wh'', ''{currency}/MWh'', ''{currency}/GJ'', ''{currency}/m³'' or ''{currency}/ft³'':"
|
||||
},
|
||||
"entity_unexpected_unit_water_price": {
|
||||
"title": "Unexpected unit of measurement",
|
||||
"description": "The following entities do not have the expected units of measurement ''{currency}/m³'' or ''{currency}/ft³'':"
|
||||
},
|
||||
"entity_unexpected_state_class": {
|
||||
"title": "Unexpected state class",
|
||||
"description": "The following entities do not have the expected state class:"
|
||||
},
|
||||
"entity_unexpected_device_class": {
|
||||
"title": "Unexpected device class",
|
||||
"description": "The following entities do not have the expected device class:"
|
||||
},
|
||||
"entity_state_class_measurement_no_last_reset": {
|
||||
"title": "Last reset missing",
|
||||
"description": "The following entities have state class 'measurement' but 'last_reset' is missing:"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"helpers": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user