mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||
import { computeStateDisplay } from "../../../common/entity/compute_state_display";
|
||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||
import "../../../components/ha-select";
|
||||
import { UNAVAILABLE } from "../../../data/entity";
|
||||
@ -76,15 +77,14 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
|
||||
? stateObj.attributes.options.map(
|
||||
(option) =>
|
||||
html`
|
||||
<mwc-list-item .value=${option}
|
||||
>${(stateObj.attributes.device_class &&
|
||||
this.hass!.localize(
|
||||
`component.select.state.${stateObj.attributes.device_class}.${option}`
|
||||
)) ||
|
||||
this.hass!.localize(
|
||||
`component.select.state._.${option}`
|
||||
) ||
|
||||
option}
|
||||
<mwc-list-item .value=${option}>
|
||||
${computeStateDisplay(
|
||||
this.hass!.localize,
|
||||
stateObj,
|
||||
this.hass!.locale,
|
||||
this.hass!.entities,
|
||||
option
|
||||
)}
|
||||
</mwc-list-item>
|
||||
`
|
||||
)
|
||||
|
@ -8,6 +8,7 @@ import "../components/entity/state-badge";
|
||||
import { UNAVAILABLE } from "../data/entity";
|
||||
import { SelectEntity, setSelectOption } from "../data/select";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import { computeStateDisplay } from "../common/entity/compute_state_display";
|
||||
|
||||
@customElement("state-card-select")
|
||||
class StateCardSelect extends LitElement {
|
||||
@ -31,12 +32,13 @@ class StateCardSelect extends LitElement {
|
||||
(option) =>
|
||||
html`
|
||||
<mwc-list-item .value=${option}>
|
||||
${(this.stateObj.attributes.device_class &&
|
||||
this.hass.localize(
|
||||
`component.select.state.${this.stateObj.attributes.device_class}.${option}`
|
||||
)) ||
|
||||
this.hass.localize(`component.select.state._.${option}`) ||
|
||||
option}
|
||||
${computeStateDisplay(
|
||||
this.hass.localize,
|
||||
this.stateObj,
|
||||
this.hass.locale,
|
||||
this.hass.entities,
|
||||
option
|
||||
)}
|
||||
</mwc-list-item>
|
||||
`
|
||||
)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user