diff --git a/src/components/entity/ha-entity-picker.ts b/src/components/entity/ha-entity-picker.ts index 393a77fb0c..d5960b3cc0 100644 --- a/src/components/entity/ha-entity-picker.ts +++ b/src/components/entity/ha-entity-picker.ts @@ -12,6 +12,7 @@ import { property, PropertyValues, TemplateResult, + query, } from "lit-element"; import memoizeOne from "memoize-one"; import { fireEvent } from "../../common/dom/fire_event"; @@ -91,12 +92,13 @@ class HaEntityPicker extends LitElement { @property() public entityFilter?: HaEntityPickerEntityFilterFunc; - @property({ type: Boolean }) private _opened?: boolean; + @property({ type: Boolean }) private _opened = false; - @property() private _hass?: HomeAssistant; + @query("vaadin-combo-box-light") private _comboBox!: HTMLElement; private _getStates = memoizeOne( ( + _opened: boolean, hass: this["hass"], includeDomains: this["includeDomains"], excludeDomains: this["excludeDomains"], @@ -147,27 +149,28 @@ class HaEntityPicker extends LitElement { ); protected updated(changedProps: PropertyValues) { - super.updated(changedProps); - - if (changedProps.has("hass") && !this._opened) { - this._hass = this.hass; + if (changedProps.has("_opened") && this._opened) { + const states = this._getStates( + this._opened, + this.hass, + this.includeDomains, + this.excludeDomains, + this.entityFilter, + this.includeDeviceClasses + ); + (this._comboBox as any).items = states; } } protected render(): TemplateResult { - const states = this._getStates( - this._hass, - this.includeDomains, - this.excludeDomains, - this.entityFilter, - this.includeDeviceClasses - ); + if (!this.hass) { + return html``; + } return html` ` : ""} - ${states.length > 0 - ? html` - - Toggle - - ` - : ""} + + + Toggle + `; diff --git a/src/panels/config/automation/action/types/ha-automation-action-scene.ts b/src/panels/config/automation/action/types/ha-automation-action-scene.ts index 3399286deb..36808b3bc5 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-scene.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-scene.ts @@ -24,7 +24,7 @@ export class HaSceneAction extends LitElement implements ActionElement { .hass=${this.hass} .value=${scene} @value-changed=${this._entityPicked} - .includeDomains=${["scene"]} + include-domains="['scene']" allow-custom-entity > `; diff --git a/src/panels/config/automation/action/types/ha-automation-action-service.ts b/src/panels/config/automation/action/types/ha-automation-action-service.ts index 4a7751e9c3..3cdbc811e2 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-service.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-service.ts @@ -34,6 +34,8 @@ export class HaServiceAction extends LitElement implements ActionElement { return { service: "", data: {} }; } + private _domain = memoizeOne((service: string) => [computeDomain(service)]); + private _getServiceData = memoizeOne((service: string) => { if (!service) { return []; @@ -85,7 +87,7 @@ export class HaServiceAction extends LitElement implements ActionElement { .value=${entity_id} .label=${entity.description} @value-changed=${this._entityPicked} - .includeDomains=${[computeDomain(service)]} + .includeDomains=${this._domain(service)} allow-custom-entity > ` diff --git a/src/panels/config/automation/condition/types/ha-automation-condition-zone.ts b/src/panels/config/automation/condition/types/ha-automation-condition-zone.ts index 213fb1966e..d330d0b50a 100644 --- a/src/panels/config/automation/condition/types/ha-automation-condition-zone.ts +++ b/src/panels/config/automation/condition/types/ha-automation-condition-zone.ts @@ -46,7 +46,7 @@ export class HaZoneCondition extends LitElement { @value-changed=${this._zonePicked} .hass=${this.hass} allow-custom-entity - .includeDomains=${["zone"]} + include-domains="['zone']" >