mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Use compute state display for select (#14736)
This commit is contained in:
parent
180357e0db
commit
5cabf1d041
@ -9,6 +9,7 @@ import {
|
|||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
|
import { computeStateDisplay } from "../../../common/entity/compute_state_display";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import "../../../components/ha-select";
|
import "../../../components/ha-select";
|
||||||
import { UNAVAILABLE } from "../../../data/entity";
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
@ -76,15 +77,14 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
? stateObj.attributes.options.map(
|
? stateObj.attributes.options.map(
|
||||||
(option) =>
|
(option) =>
|
||||||
html`
|
html`
|
||||||
<mwc-list-item .value=${option}
|
<mwc-list-item .value=${option}>
|
||||||
>${(stateObj.attributes.device_class &&
|
${computeStateDisplay(
|
||||||
this.hass!.localize(
|
this.hass!.localize,
|
||||||
`component.select.state.${stateObj.attributes.device_class}.${option}`
|
stateObj,
|
||||||
)) ||
|
this.hass!.locale,
|
||||||
this.hass!.localize(
|
this.hass!.entities,
|
||||||
`component.select.state._.${option}`
|
option
|
||||||
) ||
|
)}
|
||||||
option}
|
|
||||||
</mwc-list-item>
|
</mwc-list-item>
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
@ -8,6 +8,7 @@ import "../components/entity/state-badge";
|
|||||||
import { UNAVAILABLE } from "../data/entity";
|
import { UNAVAILABLE } from "../data/entity";
|
||||||
import { SelectEntity, setSelectOption } from "../data/select";
|
import { SelectEntity, setSelectOption } from "../data/select";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
|
import { computeStateDisplay } from "../common/entity/compute_state_display";
|
||||||
|
|
||||||
@customElement("state-card-select")
|
@customElement("state-card-select")
|
||||||
class StateCardSelect extends LitElement {
|
class StateCardSelect extends LitElement {
|
||||||
@ -31,12 +32,13 @@ class StateCardSelect extends LitElement {
|
|||||||
(option) =>
|
(option) =>
|
||||||
html`
|
html`
|
||||||
<mwc-list-item .value=${option}>
|
<mwc-list-item .value=${option}>
|
||||||
${(this.stateObj.attributes.device_class &&
|
${computeStateDisplay(
|
||||||
this.hass.localize(
|
this.hass.localize,
|
||||||
`component.select.state.${this.stateObj.attributes.device_class}.${option}`
|
this.stateObj,
|
||||||
)) ||
|
this.hass.locale,
|
||||||
this.hass.localize(`component.select.state._.${option}`) ||
|
this.hass.entities,
|
||||||
option}
|
option
|
||||||
|
)}
|
||||||
</mwc-list-item>
|
</mwc-list-item>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user