diff --git a/src/panels/config/devices/ha-config-devices-dashboard.ts b/src/panels/config/devices/ha-config-devices-dashboard.ts index 580775f805..ed14c1030f 100644 --- a/src/panels/config/devices/ha-config-devices-dashboard.ts +++ b/src/panels/config/devices/ha-config-devices-dashboard.ts @@ -199,38 +199,28 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) { } private _setFiltersFromUrl() { - if (this._searchParms.has("domain")) { - this._filters = { - ...this._filters, - "ha-filter-states": { - value: [ - ...((this._filters["ha-filter-states"]?.value as string[]) || []), - "disabled", - ], - items: undefined, - }, - "ha-filter-integrations": { - value: [this._searchParms.get("domain")!], - items: undefined, - }, - }; - } - if (this._searchParms.has("config_entry")) { - this._filters = { - ...this._filters, - "ha-filter-states": { - value: [ - ...((this._filters["ha-filter-states"]?.value as string[]) || []), - "disabled", - ], - items: undefined, - }, - config_entry: { - value: [this._searchParms.get("config_entry")!], - items: undefined, - }, - }; - } + const domain = this._searchParms.get("domain"); + const configEntry = this._searchParms.get("config_entry"); + + this._filters = { + ...this._filters, + "ha-filter-states": { + value: [ + ...((this._filters["ha-filter-states"]?.value as string[]) || []), + "disabled", + ], + items: undefined, + }, + "ha-filter-integrations": { + value: domain ? [domain] : [], + items: undefined, + }, + config_entry: { + value: configEntry ? [configEntry] : [], + items: undefined, + }, + }; + if (this._searchParms.has("label")) { this._filterLabel(); } diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 6bc6881a46..889deebd6c 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -943,6 +943,7 @@ ${ } protected firstUpdated() { + this._setFiltersFromUrl(); if (Object.keys(this._filters).length) { return; } @@ -952,39 +953,31 @@ ${ items: undefined, }, }; - this._setFiltersFromUrl(); fetchEntitySourcesWithCache(this.hass).then((sources) => { this._entitySources = sources; }); } private _setFiltersFromUrl() { - if (this._searchParms.has("domain")) { - this._filters = { - ...this._filters, - "ha-filter-states": { - value: [], - items: undefined, - }, - "ha-filter-integrations": { - value: [this._searchParms.get("domain")!], - items: undefined, - }, - }; - } - if (this._searchParms.has("config_entry")) { - this._filters = { - ...this._filters, - "ha-filter-states": { - value: [], - items: undefined, - }, - config_entry: { - value: [this._searchParms.get("config_entry")!], - items: undefined, - }, - }; - } + const domain = this._searchParms.get("domain"); + const configEntry = this._searchParms.get("config_entry"); + + this._filters = { + ...this._filters, + "ha-filter-states": { + value: [], + items: undefined, + }, + "ha-filter-integrations": { + value: domain ? [domain] : [], + items: undefined, + }, + config_entry: { + value: configEntry ? [configEntry] : [], + items: undefined, + }, + }; + if (this._searchParms.has("label")) { this._filterLabel(); }