diff --git a/src/components/entity/ha-statistic-picker.ts b/src/components/entity/ha-statistic-picker.ts index e69bf3521b..37d1ac178a 100644 --- a/src/components/entity/ha-statistic-picker.ts +++ b/src/components/entity/ha-statistic-picker.ts @@ -141,6 +141,7 @@ export class HaStatisticPicker extends LitElement { private async _getStatisticIds() { this.statisticIds = await getStatisticIds(this.hass, this.statisticTypes); + this._picker?.requestUpdate(); } private _getItems = () => @@ -177,9 +178,9 @@ export class HaStatisticPicker extends LitElement { entitiesOnly?: boolean, excludeStatistics?: string[], value?: string - ): StatisticComboBoxItem[] => { + ): StatisticComboBoxItem[] | undefined => { if (!statisticIds) { - return []; + return undefined; } if (includeStatisticsUnitOfMeasurement) { diff --git a/src/components/ha-generic-picker.ts b/src/components/ha-generic-picker.ts index 8cf4990de4..939f934f67 100644 --- a/src/components/ha-generic-picker.ts +++ b/src/components/ha-generic-picker.ts @@ -39,7 +39,7 @@ export class HaGenericPicker extends PickerMixin(LitElement) { public getItems!: ( searchString?: string, section?: string - ) => (PickerComboBoxItem | string)[]; + ) => (PickerComboBoxItem | string)[] | undefined; @property({ attribute: false, type: Array }) public getAdditionalItems?: (searchString?: string) => PickerComboBoxItem[]; diff --git a/src/components/ha-picker-combo-box.ts b/src/components/ha-picker-combo-box.ts index 349d5c4720..34f5101f0f 100644 --- a/src/components/ha-picker-combo-box.ts +++ b/src/components/ha-picker-combo-box.ts @@ -109,7 +109,7 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) { public getItems!: ( searchString?: string, section?: string - ) => PickerComboBoxItem[]; + ) => PickerComboBoxItem[] | undefined; @property({ attribute: false, type: Array }) public getAdditionalItems?: (searchString?: string) => PickerComboBoxItem[]; @@ -295,7 +295,7 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) { this.getAdditionalItems?.(searchString) || []; private _getItems = () => { - let items = [...this.getItems(this._search, this.selectedSection)]; + let items = [...(this.getItems(this._search, this.selectedSection) || [])]; if (!this.sections?.length) { items = items.sort((entityA, entityB) => {