Skip to content

Commit

Permalink
Minor fixes to energy sources behavior (#20785)
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts authored May 13, 2024
1 parent f5f2a5a commit 3ebe602
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/panels/energy/strategies/energy-view-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 3ebe602

Please sign in to comment.