mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add entity attribute value translations for humidifier (#16565)
This commit is contained in:
parent
e354f5de12
commit
d873f26db3
@ -3,14 +3,11 @@ import {
|
|||||||
HassEntityBase,
|
HassEntityBase,
|
||||||
} from "home-assistant-js-websocket";
|
} from "home-assistant-js-websocket";
|
||||||
import { FIXED_DOMAIN_STATES } from "../common/entity/get_states";
|
import { FIXED_DOMAIN_STATES } from "../common/entity/get_states";
|
||||||
import { TranslationDict } from "../types";
|
|
||||||
import { UNAVAILABLE_STATES } from "./entity";
|
import { UNAVAILABLE_STATES } from "./entity";
|
||||||
|
|
||||||
type HumidifierState =
|
type HumidifierState =
|
||||||
| (typeof FIXED_DOMAIN_STATES.humidifier)[number]
|
| (typeof FIXED_DOMAIN_STATES.humidifier)[number]
|
||||||
| (typeof UNAVAILABLE_STATES)[number];
|
| (typeof UNAVAILABLE_STATES)[number];
|
||||||
type HumidifierMode =
|
|
||||||
keyof TranslationDict["state_attributes"]["humidifier"]["mode"];
|
|
||||||
|
|
||||||
export type HumidifierEntity = HassEntityBase & {
|
export type HumidifierEntity = HassEntityBase & {
|
||||||
state: HumidifierState;
|
state: HumidifierState;
|
||||||
@ -18,8 +15,8 @@ export type HumidifierEntity = HassEntityBase & {
|
|||||||
humidity?: number;
|
humidity?: number;
|
||||||
min_humidity?: number;
|
min_humidity?: number;
|
||||||
max_humidity?: number;
|
max_humidity?: number;
|
||||||
mode?: HumidifierMode;
|
mode?: string;
|
||||||
available_modes?: HumidifierMode[];
|
available_modes?: string[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
import { property } from "lit/decorators";
|
import { property } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
import { computeAttributeValueDisplay } from "../../../common/entity/compute_attribute_display";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { supportsFeature } from "../../../common/entity/supports-feature";
|
import { supportsFeature } from "../../../common/entity/supports-feature";
|
||||||
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
||||||
@ -78,9 +79,14 @@ class MoreInfoHumidifier extends LitElement {
|
|||||||
${stateObj.attributes.available_modes!.map(
|
${stateObj.attributes.available_modes!.map(
|
||||||
(mode) => html`
|
(mode) => html`
|
||||||
<mwc-list-item .value=${mode}>
|
<mwc-list-item .value=${mode}>
|
||||||
${hass.localize(
|
${computeAttributeValueDisplay(
|
||||||
`state_attributes.humidifier.mode.${mode}`
|
hass.localize,
|
||||||
) || mode}
|
stateObj,
|
||||||
|
hass.locale,
|
||||||
|
hass.entities,
|
||||||
|
"mode",
|
||||||
|
mode
|
||||||
|
)}
|
||||||
</mwc-list-item>
|
</mwc-list-item>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
|
@ -14,6 +14,7 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
import { computeAttributeValueDisplay } from "../../../common/entity/compute_attribute_display";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
@ -135,9 +136,13 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
|||||||
${stateObj.attributes.mode && !isUnavailableState(stateObj.state)
|
${stateObj.attributes.mode && !isUnavailableState(stateObj.state)
|
||||||
? html`
|
? html`
|
||||||
-
|
-
|
||||||
${this.hass!.localize(
|
${computeAttributeValueDisplay(
|
||||||
`state_attributes.humidifier.mode.${stateObj.attributes.mode}`
|
this.hass.localize,
|
||||||
) || stateObj.attributes.mode}
|
stateObj,
|
||||||
|
this.hass.locale,
|
||||||
|
this.hass.entities,
|
||||||
|
"mode"
|
||||||
|
)}
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</text>
|
</text>
|
||||||
|
@ -5,6 +5,7 @@ import { HumidifierEntity } from "../../../data/humidifier";
|
|||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
|
import { computeAttributeValueDisplay } from "../../../common/entity/compute_attribute_display";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import { EntityConfig, LovelaceRow } from "./types";
|
import { EntityConfig, LovelaceRow } from "./types";
|
||||||
|
|
||||||
@ -49,11 +50,13 @@ class HuiHumidifierEntityRow extends LitElement implements LovelaceRow {
|
|||||||
? `${this.hass!.localize("ui.card.humidifier.humidity")}:
|
? `${this.hass!.localize("ui.card.humidifier.humidity")}:
|
||||||
${stateObj.attributes.humidity} %${
|
${stateObj.attributes.humidity} %${
|
||||||
stateObj.attributes.mode
|
stateObj.attributes.mode
|
||||||
? ` (${
|
? ` (${computeAttributeValueDisplay(
|
||||||
this.hass!.localize(
|
this.hass.localize,
|
||||||
`state_attributes.humidifier.mode.${stateObj.attributes.mode}`
|
stateObj,
|
||||||
) || stateObj.attributes.mode
|
this.hass.locale,
|
||||||
})`
|
this.hass.entities,
|
||||||
|
"mode"
|
||||||
|
)})`
|
||||||
: ""
|
: ""
|
||||||
}`
|
}`
|
||||||
: ""}
|
: ""}
|
||||||
|
@ -21,21 +21,6 @@
|
|||||||
"unavailable": "Unavailable"
|
"unavailable": "Unavailable"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"state_attributes": {
|
|
||||||
"humidifier": {
|
|
||||||
"mode": {
|
|
||||||
"normal": "Normal",
|
|
||||||
"eco": "Eco",
|
|
||||||
"away": "Away",
|
|
||||||
"boost": "Boost",
|
|
||||||
"comfort": "Comfort",
|
|
||||||
"home": "Home",
|
|
||||||
"sleep": "Sleep",
|
|
||||||
"auto": "Auto",
|
|
||||||
"baby": "Baby"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"state_badge": {
|
"state_badge": {
|
||||||
"default": {
|
"default": {
|
||||||
"unknown": "Unk",
|
"unknown": "Unk",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user