Only show config and sensor entities unless they are explicitly selected as entity ids

This commit is contained in:
Christopher Altona 2022-06-30 03:01:52 +00:00
parent 049af5b00c
commit 8ac6ae1187

View File

@ -313,6 +313,14 @@ class HaPanelHistory extends SubscribeMixin(LitElement) {
this._getHistory(); this._getHistory();
} }
private _shouldShowEntityByLargerSelection(
entity: EntityRegistryEntry
): boolean {
return (
entity.entity_category === null || entity.entity_category === "config"
);
}
private async _getHistory() { private async _getHistory() {
this._isLoading = true; this._isLoading = true;
const entityIds = this._getEntityIds(); const entityIds = this._getEntityIds();
@ -359,7 +367,9 @@ class HaPanelHistory extends SubscribeMixin(LitElement) {
const foundEntities = this._areaIdToEntities[singleSearchingAreaId]; const foundEntities = this._areaIdToEntities[singleSearchingAreaId];
if (foundEntities !== undefined) { if (foundEntities !== undefined) {
for (const foundEntity of foundEntities) { for (const foundEntity of foundEntities) {
entityIds.add(foundEntity.entity_id); if (this._shouldShowEntityByLargerSelection(foundEntity)) {
entityIds.add(foundEntity.entity_id);
}
} }
} }
const foundDevices = this._areaIdToDevices[singleSearchingAreaId]; const foundDevices = this._areaIdToDevices[singleSearchingAreaId];
@ -369,9 +379,9 @@ class HaPanelHistory extends SubscribeMixin(LitElement) {
this._deviceIdToEntities[foundDevice.id]; this._deviceIdToEntities[foundDevice.id];
for (const foundDeviceEntity of foundDeviceEntities) { for (const foundDeviceEntity of foundDeviceEntities) {
if ( if (
foundDeviceEntity.area_id === undefined || (!foundDeviceEntity.area_id ||
foundDeviceEntity.area_id === null || foundDeviceEntity.area_id === singleSearchingAreaId) &&
foundDeviceEntity.area_id === singleSearchingAreaId this._shouldShowEntityByLargerSelection(foundDeviceEntity)
) { ) {
entityIds.add(foundDeviceEntity.entity_id); entityIds.add(foundDeviceEntity.entity_id);
} }
@ -388,7 +398,9 @@ class HaPanelHistory extends SubscribeMixin(LitElement) {
const foundEntities = this._deviceIdToEntities[singleSearchingDeviceId]; const foundEntities = this._deviceIdToEntities[singleSearchingDeviceId];
if (foundEntities !== undefined) { if (foundEntities !== undefined) {
for (const foundEntity of foundEntities) { for (const foundEntity of foundEntities) {
entityIds.add(foundEntity.entity_id); if (this._shouldShowEntityByLargerSelection(foundEntity)) {
entityIds.add(foundEntity.entity_id);
}
} }
} }
} }