diff --git a/src/common/entity/compute_state_display.ts b/src/common/entity/compute_state_display.ts index 4d03b81b9c..06d748a275 100644 --- a/src/common/entity/compute_state_display.ts +++ b/src/common/entity/compute_state_display.ts @@ -96,7 +96,6 @@ export const computeStateDisplay = ( return legacyComputeStateDisplay(localize, stateObj, language); } - // Real code. if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) { return localize(`state.default.${stateObj.state}`); } @@ -141,9 +140,15 @@ export const computeStateDisplay = ( return formatDateTime(date, language); } - const deviceClass = stateObj.attributes.device_class || "_"; return ( - localize(`component.${domain}.state.${deviceClass}.${stateObj.state}`) || + // Return device class translation + (stateObj.attributes.device_class && + localize( + `component.${domain}.state.${stateObj.attributes.device_class}.${stateObj.state}` + )) || + // Return default translation + localize(`component.${domain}.state._.${stateObj.state}`) || + // We don't know! Return the raw state. stateObj.state ); }; diff --git a/src/components/ha-climate-state.js b/src/components/ha-climate-state.js index 76002a1f91..eb961cce4c 100644 --- a/src/components/ha-climate-state.js +++ b/src/components/ha-climate-state.js @@ -110,7 +110,7 @@ class HaClimateState extends LocalizeMixin(PolymerElement) { } _localizeState(localize, stateObj) { - const stateString = localize(`state.climate.${stateObj.state}`); + const stateString = localize(`component.climate.state._.${stateObj.state}`); return stateObj.attributes.hvac_action ? `${localize( `state_attributes.climate.hvac_action.${stateObj.attributes.hvac_action}` diff --git a/src/components/ha-vacuum-state.js b/src/components/ha-vacuum-state.js index 4688224380..da4ab54acd 100644 --- a/src/components/ha-vacuum-state.js +++ b/src/components/ha-vacuum-state.js @@ -76,7 +76,7 @@ class HaVacuumState extends LocalizeMixin(PolymerElement) { ? this.localize( `ui.card.vacuum.actions.${STATES_INTERCEPTABLE[state].action}` ) - : this.localize(`state.vacuum.${state}`); + : this.localize(`component.vacuum._.${state}`); } _callService(ev) { diff --git a/src/components/ha-water_heater-state.js b/src/components/ha-water_heater-state.js index 39766d0620..7cbe8b10c3 100644 --- a/src/components/ha-water_heater-state.js +++ b/src/components/ha-water_heater-state.js @@ -2,6 +2,7 @@ import { html } from "@polymer/polymer/lib/utils/html-tag"; /* eslint-plugin-disable lit */ import { PolymerElement } from "@polymer/polymer/polymer-element"; import LocalizeMixin from "../mixins/localize-mixin"; +import { computeStateDisplay } from "../common/entity/compute_state_display"; /* * @appliesMixin LocalizeMixin @@ -32,7 +33,7 @@ class HaWaterHeaterState extends LocalizeMixin(PolymerElement) {