Revert "Filter unrecorded entities from history panel (#19621)" (#20941)

This reverts commit d88670034a7c272ec0b9ad545eff173a03f9a09c.
This commit is contained in:
karwosts 2024-06-03 01:03:30 -07:00 committed by GitHub
parent c55720c933
commit d7cb4cb537
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 52 deletions

View File

@ -12,14 +12,6 @@ export interface RecorderInfo {
thread_running: boolean; thread_running: boolean;
} }
export interface RecordedEntities {
entity_ids: string[];
}
export interface RecordedExcludedEntities {
recorded_ids: string[];
excluded_ids: string[];
}
export type StatisticType = "change" | "state" | "sum" | "min" | "max" | "mean"; export type StatisticType = "change" | "state" | "sum" | "min" | "max" | "mean";
export interface Statistics { export interface Statistics {
@ -332,25 +324,3 @@ export const getDisplayUnit = (
export const isExternalStatistic = (statisticsId: string): boolean => export const isExternalStatistic = (statisticsId: string): boolean =>
statisticsId.includes(":"); statisticsId.includes(":");
let recordedExcludedEntitiesCache: RecordedExcludedEntities | undefined;
export const getRecordedExcludedEntities = async (
hass: HomeAssistant
): Promise<RecordedExcludedEntities> => {
if (recordedExcludedEntitiesCache) {
return recordedExcludedEntitiesCache;
}
const recordedEntities = await hass.callWS<RecordedEntities>({
type: "recorder/recorded_entities",
});
recordedExcludedEntitiesCache = {
recorded_ids: recordedEntities.entity_ids,
excluded_ids: Object.keys(hass.states).filter(
(id) => !recordedEntities.entity_ids.includes(id)
),
};
return recordedExcludedEntitiesCache;
};

View File

@ -6,7 +6,6 @@ import {
} from "@mdi/js"; } from "@mdi/js";
import { ActionDetail } from "@material/mwc-list"; import { ActionDetail } from "@material/mwc-list";
import { differenceInHours } from "date-fns"; import { differenceInHours } from "date-fns";
import { HassEntity } from "home-assistant-js-websocket";
import { import {
HassServiceTarget, HassServiceTarget,
UnsubscribeFunc, UnsubscribeFunc,
@ -46,11 +45,7 @@ import {
computeHistory, computeHistory,
subscribeHistory, subscribeHistory,
} from "../../data/history"; } from "../../data/history";
import { import { Statistics, fetchStatistics } from "../../data/recorder";
fetchStatistics,
Statistics,
getRecordedExcludedEntities,
} from "../../data/recorder";
import { import {
expandAreaTarget, expandAreaTarget,
expandDeviceTarget, expandDeviceTarget,
@ -100,8 +95,6 @@ class HaPanelHistory extends LitElement {
private _interval?: number; private _interval?: number;
private _excludedEntities?: string[];
public constructor() { public constructor() {
super(); super();
@ -192,7 +185,6 @@ class HaPanelHistory extends LitElement {
.hass=${this.hass} .hass=${this.hass}
.value=${this._targetPickerValue} .value=${this._targetPickerValue}
.disabled=${this._isLoading} .disabled=${this._isLoading}
.entityFilter=${this._entityFilter}
addOnTop addOnTop
@value-changed=${this._targetsChanged} @value-changed=${this._targetsChanged}
></ha-target-picker> ></ha-target-picker>
@ -219,10 +211,6 @@ class HaPanelHistory extends LitElement {
`; `;
} }
private _entityFilter = (entity: HassEntity): boolean =>
!this._excludedEntities ||
!this._excludedEntities.includes(entity.entity_id);
private mergeHistoryResults( private mergeHistoryResults(
ltsResult: HistoryResult, ltsResult: HistoryResult,
historyResult: HistoryResult historyResult: HistoryResult
@ -374,17 +362,8 @@ class HaPanelHistory extends LitElement {
} }
} }
private async _getRecordedExcludedEntities() {
const { recorded_ids: _recordedIds, excluded_ids: excludedIds } =
await getRecordedExcludedEntities(this.hass);
this._excludedEntities = excludedIds;
}
protected firstUpdated(changedProps: PropertyValues) { protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
this._getRecordedExcludedEntities();
const searchParams = extractSearchParamsObject(); const searchParams = extractSearchParamsObject();
if (searchParams.back === "1" && history.length > 1) { if (searchParams.back === "1" && history.length > 1) {
this._showBack = true; this._showBack = true;