diff --git a/src/components/device/ha-device-picker.ts b/src/components/device/ha-device-picker.ts index ae804b680388..35e16fd4eae6 100644 --- a/src/components/device/ha-device-picker.ts +++ b/src/components/device/ha-device-picker.ts @@ -10,7 +10,6 @@ import { ScorableTextItem, fuzzyFilterSort, } from "../../common/string/filter/sequence-matching"; -import { AreaRegistryEntry } from "../../data/area_registry"; import { DeviceEntityDisplayLookup, DeviceRegistryEntry, @@ -102,7 +101,7 @@ export class HaDevicePicker extends LitElement { private _getDevices = memoizeOne( ( devices: DeviceRegistryEntry[], - areas: AreaRegistryEntry[], + areas: HomeAssistant["areas"], entities: EntityRegistryDisplayEntry[], includeDomains: this["includeDomains"], excludeDomains: this["excludeDomains"], @@ -133,11 +132,6 @@ export class HaDevicePicker extends LitElement { deviceEntityLookup = getDeviceEntityDisplayLookup(entities); } - const areaLookup: { [areaId: string]: AreaRegistryEntry } = {}; - for (const area of areas) { - areaLookup[area.area_id] = area; - } - let inputDevices = devices.filter( (device) => device.id === this.value || !device.disabled_by ); @@ -227,8 +221,8 @@ export class HaDevicePicker extends LitElement { id: device.id, name: name, area: - device.area_id && areaLookup[device.area_id] - ? areaLookup[device.area_id].name + device.area_id && areas[device.area_id] + ? areas[device.area_id].name : this.hass.localize("ui.components.device-picker.no_area"), strings: [name || ""], }; @@ -270,7 +264,7 @@ export class HaDevicePicker extends LitElement { this._init = true; const devices = this._getDevices( Object.values(this.hass.devices), - Object.values(this.hass.areas), + this.hass.areas, Object.values(this.hass.entities), this.includeDomains, this.excludeDomains,