Support to|from null in UI for ha-automation-trigger-state (#15071)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
karwosts
2023-05-31 05:28:16 -07:00
committed by GitHub
parent aea668e754
commit 5217d427e9
6 changed files with 70 additions and 9 deletions

View File

@@ -19,6 +19,8 @@ class HaEntityStatePicker extends LitElement {
@property() public attribute?: string;
@property() public extraOptions?: any[];
@property({ type: Boolean }) public autofocus = false;
@property({ type: Boolean }) public disabled = false;
@@ -43,10 +45,16 @@ class HaEntityStatePicker extends LitElement {
}
protected updated(changedProps: PropertyValues) {
if (changedProps.has("_opened") && this._opened) {
if (
(changedProps.has("_opened") && this._opened) ||
changedProps.has("entityId") ||
changedProps.has("attribute") ||
changedProps.has("extraOptions")
) {
const state = this.entityId ? this.hass.states[this.entityId] : undefined;
(this._comboBox as any).items =
this.entityId && state
(this._comboBox as any).items = [
...(this.extraOptions ?? []),
...(this.entityId && state
? getStates(state, this.attribute).map((key) => ({
value: key,
label: !this.attribute
@@ -66,7 +74,8 @@ class HaEntityStatePicker extends LitElement {
key
),
}))
: [];
: []),
];
}
}