diff --git a/src/panels/config/entity_registry/ha-config-entity-registry.ts b/src/panels/config/entity_registry/ha-config-entity-registry.ts index 96990ff9db..e720e6e319 100644 --- a/src/panels/config/entity_registry/ha-config-entity-registry.ts +++ b/src/panels/config/entity_registry/ha-config-entity-registry.ts @@ -7,6 +7,7 @@ import { property, } from "lit-element"; import "@polymer/paper-item/paper-icon-item"; +import "@polymer/paper-item/paper-item"; import "@polymer/paper-item/paper-item-body"; import { HomeAssistant } from "../../../types"; @@ -19,6 +20,7 @@ import "../../../layouts/hass-subpage"; import "../../../layouts/hass-loading-screen"; import "../../../components/ha-card"; import "../../../components/ha-icon"; +import "../../../components/ha-switch"; import { domainIcon } from "../../../common/entity/domain_icon"; import { stateIcon } from "../../../common/entity/state_icon"; import { computeDomain } from "../../../common/entity/compute_domain"; @@ -30,13 +32,24 @@ import { import { UnsubscribeFunc } from "home-assistant-js-websocket"; import { compare } from "../../../common/string/compare"; import { classMap } from "lit-html/directives/class-map"; +// tslint:disable-next-line +import { HaSwitch } from "../../../components/ha-switch"; +import memoize from "memoize-one"; class HaConfigEntityRegistry extends LitElement { @property() public hass!: HomeAssistant; @property() public isWide?: boolean; @property() private _entities?: EntityRegistryEntry[]; + @property() private _showDisabled = false; private _unsubEntities?: UnsubscribeFunc; + private _filteredEntities = memoize( + (entities: EntityRegistryEntry[], showDisabled: boolean) => + showDisabled + ? entities + : entities.filter((entity) => !Boolean(entity.disabled_by)) + ); + public disconnectedCallback() { super.disconnectedCallback(); if (this._unsubEntities) { @@ -78,40 +91,53 @@ class HaConfigEntityRegistry extends LitElement { - ${this._entities.map((entry) => { - const state = this.hass!.states[entry.entity_id]; - return html` - - - -
- ${computeEntityRegistryName(this.hass!, entry) || - `(${this.hass!.localize("state.default.unavailable")})`} + + ${this.hass.localize( + "ui.panel.config.entity_registry.picker.show_disabled" + )} + ${this._filteredEntities(this._entities, this._showDisabled).map( + (entry) => { + const state = this.hass!.states[entry.entity_id]; + return html` + + + +
+ ${computeEntityRegistryName(this.hass!, entry) || + `(${this.hass!.localize( + "state.default.unavailable" + )})`} +
+
+ ${entry.entity_id} +
+
+
+ ${entry.platform} + ${entry.disabled_by + ? html` +
(disabled) + ` + : ""}
-
- ${entry.entity_id} -
- -
- ${entry.platform} - ${entry.disabled_by - ? html` -
(disabled) - ` - : ""} -
-
- `; - })} + + `; + } + )} @@ -137,6 +163,10 @@ class HaConfigEntityRegistry extends LitElement { } } + private _showDisabledChanged(ev: Event) { + this._showDisabled = (ev.target as HaSwitch).checked; + } + private _openEditEntry(ev: MouseEvent): void { const entry = (ev.currentTarget! as any).entry; showEntityRegistryDetailDialog(this, { diff --git a/src/translations/en.json b/src/translations/en.json index 6010e2bf79..8af25be437 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -921,7 +921,8 @@ "header": "Entity Registry", "introduction": "Home Assistant keeps a registry of every entity it has ever seen that can be uniquely identified. Each of these entities will have an entity ID assigned which will be reserved for just this entity.", "introduction2": "Use the entity registry to override the name, change the entity ID or remove the entry from Home Assistant. Note, removing the entity registry entry won't remove the entity. To do that, follow the link below and remove it from the integrations page.", - "integrations_page": "Integrations page" + "integrations_page": "Integrations page", + "show_disabled": "Show disabled entities" }, "editor": { "unavailable": "This entity is not currently available.",