mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-14 13:31:10 +00:00
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:
@@ -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
|
||||
),
|
||||
}))
|
||||
: [];
|
||||
: []),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user