Fix device selector when picking devices with no entities (#16734)

This commit is contained in:
karwosts 2023-06-02 02:26:07 -07:00 committed by GitHub
parent 27451ca30e
commit b1f5ff26d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,7 +77,9 @@ export class HaDeviceSelector extends LitElement {
.label=${this.label} .label=${this.label}
.helper=${this.helper} .helper=${this.helper}
.deviceFilter=${this._filterDevices} .deviceFilter=${this._filterDevices}
.entityFilter=${this._filterEntities} .entityFilter=${this.selector.device?.entity
? this._filterEntities
: undefined}
.disabled=${this.disabled} .disabled=${this.disabled}
.required=${this.required} .required=${this.required}
allow-custom-entity allow-custom-entity
@ -92,7 +94,9 @@ export class HaDeviceSelector extends LitElement {
.value=${this.value} .value=${this.value}
.helper=${this.helper} .helper=${this.helper}
.deviceFilter=${this._filterDevices} .deviceFilter=${this._filterDevices}
.entityFilter=${this._filterEntities} .entityFilter=${this.selector.device?.entity
? this._filterEntities
: undefined}
.disabled=${this.disabled} .disabled=${this.disabled}
.required=${this.required} .required=${this.required}
></ha-devices-picker> ></ha-devices-picker>
@ -115,14 +119,10 @@ export class HaDeviceSelector extends LitElement {
); );
}; };
private _filterEntities = (entity: HassEntity): boolean => { private _filterEntities = (entity: HassEntity): boolean =>
if (!this.selector.device?.entity) { ensureArray(this.selector.device!.entity).some((filter) =>
return true;
}
return ensureArray(this.selector.device.entity).some((filter) =>
filterSelectorEntities(filter, entity, this._entitySources) filterSelectorEntities(filter, entity, this._entitySources)
); );
};
} }
declare global { declare global {