From 419d659311b10ace1f49850e2bf17c6a8d8f60e8 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 31 Mar 2022 18:32:10 -0700 Subject: [PATCH] Guard calling input select row with bad option (#12181) --- .../lovelace/entity-rows/hui-select-entity-row.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/entity-rows/hui-select-entity-row.ts b/src/panels/lovelace/entity-rows/hui-select-entity-row.ts index 5cc2ab0ee9..a169cbe565 100644 --- a/src/panels/lovelace/entity-rows/hui-select-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-select-entity-row.ts @@ -13,6 +13,7 @@ import { computeStateName } from "../../../common/entity/compute_state_name"; import "../../../components/ha-select"; import { UNAVAILABLE } from "../../../data/entity"; import { forwardHaptic } from "../../../data/haptics"; +import type { InputSelectEntity } from "../../../data/input_select"; import { SelectEntity, setSelectOption } from "../../../data/select"; import { HomeAssistant } from "../../../types"; import { EntitiesCardEntityConfig } from "../cards/types"; @@ -106,9 +107,14 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow { } private _selectedChanged(ev): void { - const stateObj = this.hass!.states[this._config!.entity]; + const stateObj = this.hass!.states[ + this._config!.entity + ] as InputSelectEntity; const option = ev.target.value; - if (option === stateObj.state) { + if ( + option === stateObj.state || + !stateObj.attributes.options.includes(option) + ) { return; }