mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-17 06:16:33 +00:00
Little cleanup (#11461)
This commit is contained in:
parent
f04b844223
commit
ba75c2e7af
@ -3,7 +3,7 @@ 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 { EnergyPreferences, getEnergyPreferences } from "../../../data/energy";
|
||||
import { getEnergyPreferences } from "../../../data/energy";
|
||||
import { subscribeEntityRegistry } from "../../../data/entity_registry";
|
||||
import { generateDefaultViewConfig } from "../common/generate-lovelace-config";
|
||||
import {
|
||||
@ -39,30 +39,18 @@ export class OriginalStatesStrategy {
|
||||
subscribeEntityRegistry(hass.connection, () => undefined);
|
||||
}
|
||||
|
||||
let energyPromise: Promise<EnergyPreferences> | undefined;
|
||||
|
||||
if (isComponentLoaded(hass, "energy")) {
|
||||
energyPromise = getEnergyPreferences(hass);
|
||||
}
|
||||
|
||||
const [areaEntries, deviceEntries, entityEntries, localize] =
|
||||
const [areaEntries, deviceEntries, entityEntries, localize, energyPrefs] =
|
||||
await Promise.all([
|
||||
subscribeOne(hass.connection, subscribeAreaRegistry),
|
||||
subscribeOne(hass.connection, subscribeDeviceRegistry),
|
||||
subscribeOne(hass.connection, subscribeEntityRegistry),
|
||||
hass.loadBackendTranslation("title"),
|
||||
isComponentLoaded(hass, "energy")
|
||||
? // It raises if not configured, just swallow that.
|
||||
getEnergyPreferences(hass).catch(() => undefined)
|
||||
: undefined,
|
||||
]);
|
||||
|
||||
let energyPrefs: EnergyPreferences | undefined;
|
||||
|
||||
if (energyPromise) {
|
||||
try {
|
||||
energyPrefs = await energyPromise;
|
||||
} catch (_) {
|
||||
// Nothing to do here
|
||||
}
|
||||
}
|
||||
|
||||
// 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