From 8ac6ae118750da263e5947ab7bd50230fa08dccd Mon Sep 17 00:00:00 2001 From: Christopher Altona Date: Thu, 30 Jun 2022 03:01:52 +0000 Subject: [PATCH] Only show config and sensor entities unless they are explicitly selected as entity ids --- src/panels/history/ha-panel-history.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/panels/history/ha-panel-history.ts b/src/panels/history/ha-panel-history.ts index ec915fbb00..7523135cbd 100644 --- a/src/panels/history/ha-panel-history.ts +++ b/src/panels/history/ha-panel-history.ts @@ -313,6 +313,14 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { this._getHistory(); } + private _shouldShowEntityByLargerSelection( + entity: EntityRegistryEntry + ): boolean { + return ( + entity.entity_category === null || entity.entity_category === "config" + ); + } + private async _getHistory() { this._isLoading = true; const entityIds = this._getEntityIds(); @@ -359,7 +367,9 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { const foundEntities = this._areaIdToEntities[singleSearchingAreaId]; if (foundEntities !== undefined) { for (const foundEntity of foundEntities) { - entityIds.add(foundEntity.entity_id); + if (this._shouldShowEntityByLargerSelection(foundEntity)) { + entityIds.add(foundEntity.entity_id); + } } } const foundDevices = this._areaIdToDevices[singleSearchingAreaId]; @@ -369,9 +379,9 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { this._deviceIdToEntities[foundDevice.id]; for (const foundDeviceEntity of foundDeviceEntities) { if ( - foundDeviceEntity.area_id === undefined || - foundDeviceEntity.area_id === null || - foundDeviceEntity.area_id === singleSearchingAreaId + (!foundDeviceEntity.area_id || + foundDeviceEntity.area_id === singleSearchingAreaId) && + this._shouldShowEntityByLargerSelection(foundDeviceEntity) ) { entityIds.add(foundDeviceEntity.entity_id); } @@ -388,7 +398,9 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { const foundEntities = this._deviceIdToEntities[singleSearchingDeviceId]; if (foundEntities !== undefined) { for (const foundEntity of foundEntities) { - entityIds.add(foundEntity.entity_id); + if (this._shouldShowEntityByLargerSelection(foundEntity)) { + entityIds.add(foundEntity.entity_id); + } } } }