This commit is contained in:
Cody C 2024-04-27 20:05:31 +02:00 committed by GitHub
commit 2fec28ff96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -137,6 +137,17 @@ export class EnergySetupWizard extends LitElement implements LovelaceCard {
if (!this._preferences) {
return;
}
// User made no selections during setup
if (
this._preferences!.device_consumption.length === 0 &&
this._preferences!.energy_sources.length === 0
) {
showAlertDialog(this, {
title: `No statistics selected`,
text: `You must select at least one statistic to finish setting up your Energy dashboard.`,
});
return;
}
try {
this._preferences = await saveEnergyPreferences(
this.hass,

View File

@ -44,6 +44,14 @@ export class EnergyViewStrategy extends ReactiveElement {
return view;
}
// No energy sources available, start from scratch
if (
prefs!.device_consumption.length === 0 &&
prefs!.energy_sources.length === 0
) {
return setupWizard();
}
view.type = "sidebar";
const hasGrid = prefs.energy_sources.find(