diff --git a/src/components/device/ha-device-picker.ts b/src/components/device/ha-device-picker.ts index 485698fdff..0d9aff55e3 100644 --- a/src/components/device/ha-device-picker.ts +++ b/src/components/device/ha-device-picker.ts @@ -190,8 +190,9 @@ class HaDevicePicker extends SubscribeMixin(LitElement) { `; } - private _clearValue() { - this.value = ""; + private _clearValue(ev: Event) { + ev.stopPropagation(); + this._setValue(""); } private get _value() { @@ -206,14 +207,18 @@ class HaDevicePicker extends SubscribeMixin(LitElement) { const newValue = ev.detail.value; if (newValue !== this._value) { - this.value = newValue; - setTimeout(() => { - fireEvent(this, "value-changed", { value: newValue }); - fireEvent(this, "change"); - }, 0); + this._setValue(newValue); } } + private _setValue(value: string) { + this.value = value; + setTimeout(() => { + fireEvent(this, "value-changed", { value }); + fireEvent(this, "change"); + }, 0); + } + static get styles(): CSSResult { return css` paper-input > paper-icon-button { diff --git a/src/components/entity/ha-entity-picker.ts b/src/components/entity/ha-entity-picker.ts index 1ade8bff2f..a6d1b8d720 100644 --- a/src/components/entity/ha-entity-picker.ts +++ b/src/components/entity/ha-entity-picker.ts @@ -192,8 +192,9 @@ class HaEntityPicker extends LitElement { `; } - private _clearValue() { - this.value = ""; + private _clearValue(ev: Event) { + ev.stopPropagation(); + this._setValue(""); } private get _value() { @@ -207,14 +208,18 @@ class HaEntityPicker extends LitElement { private _valueChanged(ev: PolymerChangedEvent) { const newValue = ev.detail.value; if (newValue !== this._value) { - this.value = ev.detail.value; - setTimeout(() => { - fireEvent(this, "value-changed", { value: this.value }); - fireEvent(this, "change"); - }, 0); + this._setValue(newValue); } } + private _setValue(value: string) { + this.value = value; + setTimeout(() => { + fireEvent(this, "value-changed", { value }); + fireEvent(this, "change"); + }, 0); + } + static get styles(): CSSResult { return css` paper-input > paper-icon-button { diff --git a/src/panels/developer-tools/state/developer-tools-state.js b/src/panels/developer-tools/state/developer-tools-state.js index bf15c25a68..8312f15e34 100644 --- a/src/panels/developer-tools/state/developer-tools-state.js +++ b/src/panels/developer-tools/state/developer-tools-state.js @@ -240,6 +240,11 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) { } entityIdChanged() { + if (this._entityId === "") { + this._state = ""; + this._stateAttributes = ""; + return; + } var state = this.hass.states[this._entityId]; this._state = state.state; this._stateAttributes = safeDump(state.attributes);