Skip to content

Commit

Permalink
better fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten committed Dec 8, 2023
1 parent 144bffb commit 56322a6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/components/device/ha-device-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ScorableTextItem,
fuzzyFilterSort,
} from "../../common/string/filter/sequence-matching";
import { AreaRegistryEntry } from "../../data/area_registry";
import {
DeviceEntityDisplayLookup,
DeviceRegistryEntry,
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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 || ""],
};
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 56322a6

Please sign in to comment.