Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to energy sources behavior #20785

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading