Allow controlling an input_select in unknown state (#13524)

This commit is contained in:
Erik Montnemery 2022-08-30 20:24:05 +02:00 committed by GitHub
parent e861460318
commit cb5621032d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import { customElement, property, state } from "lit/decorators";
import { stopPropagation } from "../../../common/dom/stop_propagation"; import { stopPropagation } from "../../../common/dom/stop_propagation";
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_STATES } from "../../../data/entity"; import { UNAVAILABLE } from "../../../data/entity";
import { forwardHaptic } from "../../../data/haptics"; import { forwardHaptic } from "../../../data/haptics";
import { import {
InputSelectEntity, InputSelectEntity,
@ -61,7 +61,9 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
<ha-select <ha-select
.label=${this._config.name || computeStateName(stateObj)} .label=${this._config.name || computeStateName(stateObj)}
.value=${stateObj.state} .value=${stateObj.state}
.disabled=${UNAVAILABLE_STATES.includes(stateObj.state)} .disabled=${
stateObj.state === UNAVAILABLE /* UNKNWON state is allowed */
}
naturalMenuWidth naturalMenuWidth
@selected=${this._selectedChanged} @selected=${this._selectedChanged}
@click=${stopPropagation} @click=${stopPropagation}

View File

@ -5,7 +5,7 @@ import { customElement, property } from "lit/decorators";
import { stopPropagation } from "../common/dom/stop_propagation"; import { stopPropagation } from "../common/dom/stop_propagation";
import { computeStateName } from "../common/entity/compute_state_name"; import { computeStateName } from "../common/entity/compute_state_name";
import "../components/entity/state-badge"; import "../components/entity/state-badge";
import { UNAVAILABLE_STATES } from "../data/entity"; import { UNAVAILABLE } from "../data/entity";
import { InputSelectEntity, setInputSelectOption } from "../data/input_select"; import { InputSelectEntity, setInputSelectOption } from "../data/input_select";
import type { HomeAssistant } from "../types"; import type { HomeAssistant } from "../types";
@ -21,7 +21,9 @@ class StateCardInputSelect extends LitElement {
<ha-select <ha-select
.label=${computeStateName(this.stateObj)} .label=${computeStateName(this.stateObj)}
.value=${this.stateObj.state} .value=${this.stateObj.state}
.disabled=${UNAVAILABLE_STATES.includes(this.stateObj.state)} .disabled=${
this.stateObj.state === UNAVAILABLE /* UNKNWON state is allowed */
}
naturalMenuWidth naturalMenuWidth
fixedMenuPosition fixedMenuPosition
@selected=${this._selectedOptionChanged} @selected=${this._selectedOptionChanged}