mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Hardcode history card stub entity to sun.sun (#7760)
This commit is contained in:
parent
8e4ceb7d48
commit
7b392b626b
@ -16,7 +16,6 @@ import "../../../components/state-history-charts";
|
|||||||
import { CacheConfig, getRecentWithCache } from "../../../data/cached-history";
|
import { CacheConfig, getRecentWithCache } from "../../../data/cached-history";
|
||||||
import { HistoryResult } from "../../../data/history";
|
import { HistoryResult } from "../../../data/history";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { findEntities } from "../common/find-entites";
|
|
||||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
import { EntityConfig } from "../entity-rows/types";
|
import { EntityConfig } from "../entity-rows/types";
|
||||||
@ -30,22 +29,9 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
return document.createElement("hui-history-graph-card-editor");
|
return document.createElement("hui-history-graph-card-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getStubConfig(
|
public static getStubConfig(): HistoryGraphCardConfig {
|
||||||
hass: HomeAssistant,
|
// Hard coded to sun.sun to prevent high server load when it would pick an entity with a lot of state changes
|
||||||
entities: string[],
|
return { type: "history-graph", entities: ["sun.sun"] };
|
||||||
entitiesFallback: string[]
|
|
||||||
): HistoryGraphCardConfig {
|
|
||||||
const includeDomains = ["sensor"];
|
|
||||||
const maxEntities = 1;
|
|
||||||
const foundEntities = findEntities(
|
|
||||||
hass,
|
|
||||||
maxEntities,
|
|
||||||
entities,
|
|
||||||
entitiesFallback,
|
|
||||||
includeDomains
|
|
||||||
);
|
|
||||||
|
|
||||||
return { type: "history-graph", entities: foundEntities };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
@ -71,12 +57,12 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setConfig(config: HistoryGraphCardConfig): void {
|
public setConfig(config: HistoryGraphCardConfig): void {
|
||||||
if (!config.entities.length) {
|
if (!config.entities || !Array.isArray(config.entities)) {
|
||||||
throw new Error("Entities must be specified");
|
throw new Error("Entities need to be an array");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.entities && !Array.isArray(config.entities)) {
|
if (!config.entities.length) {
|
||||||
throw new Error("Entities need to be an array");
|
throw new Error("You must include at least one entity");
|
||||||
}
|
}
|
||||||
|
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user