Reapply filters if entity registry change (#20265)

This commit is contained in:
Paul Bottein 2024-03-29 11:37:13 +01:00 committed by GitHub
parent d1119a3b61
commit 520581c165
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 11 deletions

View File

@ -10,7 +10,7 @@ import { computeDomain } from "../common/entity/compute_domain";
export { subscribeEntityRegistryDisplay } from "./ws-entity_registry_display";
type entityCategory = "config" | "diagnostic";
type EntityCategory = "config" | "diagnostic";
export interface EntityRegistryDisplayEntry {
entity_id: string;
@ -20,7 +20,7 @@ export interface EntityRegistryDisplayEntry {
area_id?: string;
labels: string[];
hidden?: boolean;
entity_category?: entityCategory;
entity_category?: EntityCategory;
translation_key?: string;
platform?: string;
display_precision?: number;
@ -40,7 +40,7 @@ export interface EntityRegistryDisplayEntryResponse {
hb?: boolean;
dp?: number;
}[];
entity_categories: Record<number, entityCategory>;
entity_categories: Record<number, EntityCategory>;
}
export interface EntityRegistryEntry {
@ -55,7 +55,7 @@ export interface EntityRegistryEntry {
labels: string[];
disabled_by: "user" | "device" | "integration" | "config_entry" | null;
hidden_by: Exclude<EntityRegistryEntry["disabled_by"], "config_entry">;
entity_category: entityCategory | null;
entity_category: EntityCategory | null;
has_entity_name: boolean;
original_name?: string;
unique_id: string;

View File

@ -18,6 +18,7 @@ import { UnsubscribeFunc } from "home-assistant-js-websocket";
import {
CSSResultGroup,
LitElement,
PropertyValues,
TemplateResult,
css,
html,
@ -38,13 +39,15 @@ import type {
DataTableColumnContainer,
RowClickedEvent,
} from "../../../components/data-table/ha-data-table";
import "../../../components/data-table/ha-data-table-labels";
import "../../../components/entity/ha-entity-toggle";
import "../../../components/ha-fab";
import "../../../components/ha-filter-floor-areas";
import "../../../components/ha-filter-blueprints";
import "../../../components/ha-filter-categories";
import "../../../components/ha-filter-devices";
import "../../../components/ha-filter-entities";
import "../../../components/ha-filter-floor-areas";
import "../../../components/ha-filter-labels";
import "../../../components/ha-icon-button";
import "../../../components/ha-icon-overflow-menu";
import "../../../components/ha-svg-icon";
@ -64,6 +67,10 @@ import {
import { fullEntitiesContext } from "../../../data/context";
import { UNAVAILABLE } from "../../../data/entity";
import { EntityRegistryEntry } from "../../../data/entity_registry";
import {
LabelRegistryEntry,
subscribeLabelRegistry,
} from "../../../data/label_registry";
import { findRelated } from "../../../data/search";
import {
showAlertDialog,
@ -77,12 +84,6 @@ import { documentationUrl } from "../../../util/documentation-url";
import { showAssignCategoryDialog } from "../category/show-dialog-assign-category";
import { configSections } from "../ha-panel-config";
import { showNewAutomationDialog } from "./show-dialog-new-automation";
import "../../../components/data-table/ha-data-table-labels";
import {
LabelRegistryEntry,
subscribeLabelRegistry,
} from "../../../data/label_registry";
import "../../../components/ha-filter-labels";
type AutomationItem = AutomationEntity & {
name: string;
@ -509,6 +510,13 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
`;
}
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
if (changedProps.has("_entityReg")) {
this._applyFilters();
}
}
firstUpdated() {
if (this._searchParms.has("blueprint")) {
this._filterBlueprint();

View File

@ -16,6 +16,7 @@ import { UnsubscribeFunc } from "home-assistant-js-websocket";
import {
CSSResultGroup,
LitElement,
PropertyValues,
TemplateResult,
css,
html,
@ -297,6 +298,13 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
}
);
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
if (changedProps.has("_entityReg")) {
this._applyFilters();
}
}
protected hassSubscribe(): (UnsubscribeFunc | Promise<UnsubscribeFunc>)[] {
return [
subscribeCategoryRegistry(this.hass.connection, "scene", (categories) => {

View File

@ -15,6 +15,7 @@ import { UnsubscribeFunc } from "home-assistant-js-websocket";
import {
CSSResultGroup,
LitElement,
PropertyValues,
TemplateResult,
css,
html,
@ -560,6 +561,13 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
this._filteredScripts = items ? [...items] : undefined;
}
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
if (changedProps.has("_entityReg")) {
this._applyFilters();
}
}
firstUpdated() {
if (this._searchParms.has("blueprint")) {
this._filterBlueprint();