Minor fixes to energy sources behavior (#20785)

This commit is contained in:
karwosts 2024-05-13 09:41:51 -07:00 committed by GitHub
parent f5f2a5ad5b
commit 3ebe6027be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -47,7 +47,9 @@ export class EnergyViewStrategy extends ReactiveElement {
view.type = "sidebar";
const hasGrid = prefs.energy_sources.find(
(source) => source.type === "grid"
(source) =>
source.type === "grid" &&
(source.flow_from?.length || source.flow_to?.length)
) as GridSourceTypeEnergyPreference;
const hasReturn = hasGrid && hasGrid.flow_to.length;
const hasSolar = prefs.energy_sources.some(
@ -110,7 +112,7 @@ export class EnergyViewStrategy extends ReactiveElement {
});
}
if (hasGrid || hasSolar) {
if (hasGrid || hasSolar || hasGas || hasWater) {
view.cards!.push({
title: hass.localize(
"ui.panel.energy.cards.energy_sources_table_title"

View File

@ -694,7 +694,9 @@ export class HuiEnergySourcesTableCard
</tr>`;
})}`
)}
${types.grid
${types.grid &&
(types.grid?.[0].flow_from?.length ||
types.grid?.[0].flow_to?.length)
? html` <tr class="mdc-data-table__row total">
<td class="mdc-data-table__cell"></td>
<th class="mdc-data-table__cell" scope="row">