mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47:20 +00:00
Do not query energy prefs if it's not loaded (#9763)
This commit is contained in:
parent
34f8e5e28d
commit
29d29a337f
@ -1,8 +1,9 @@
|
||||
import { STATE_NOT_RUNNING } from "home-assistant-js-websocket";
|
||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||
import { subscribeOne } from "../../../common/util/subscribe-one";
|
||||
import { subscribeAreaRegistry } from "../../../data/area_registry";
|
||||
import { subscribeDeviceRegistry } from "../../../data/device_registry";
|
||||
import { getEnergyPreferences } from "../../../data/energy";
|
||||
import { EnergyPreferences, getEnergyPreferences } from "../../../data/energy";
|
||||
import { subscribeEntityRegistry } from "../../../data/entity_registry";
|
||||
import { generateDefaultViewConfig } from "../common/generate-lovelace-config";
|
||||
import {
|
||||
@ -38,16 +39,22 @@ export class OriginalStatesStrategy {
|
||||
subscribeEntityRegistry(hass.connection, () => undefined);
|
||||
}
|
||||
|
||||
const [areaEntries, deviceEntries, entityEntries, localize, energyPrefs] =
|
||||
let energyPromise: Promise<EnergyPreferences> | undefined;
|
||||
|
||||
if (isComponentLoaded(hass, "energy")) {
|
||||
energyPromise = getEnergyPreferences(hass);
|
||||
}
|
||||
|
||||
const [areaEntries, deviceEntries, entityEntries, localize] =
|
||||
await Promise.all([
|
||||
subscribeOne(hass.connection, subscribeAreaRegistry),
|
||||
subscribeOne(hass.connection, subscribeDeviceRegistry),
|
||||
subscribeOne(hass.connection, subscribeEntityRegistry),
|
||||
hass.loadBackendTranslation("title"),
|
||||
// It raises if not configured, just swallow that.
|
||||
getEnergyPreferences(hass).catch(() => undefined),
|
||||
]);
|
||||
|
||||
const energyPrefs = energyPromise ? await energyPromise : undefined;
|
||||
|
||||
// User can override default view. If they didn't, we will add one
|
||||
// that contains all entities.
|
||||
const view = generateDefaultViewConfig(
|
||||
|
Loading…
x
Reference in New Issue
Block a user