Skip to content

Commit ab00be6

Browse files
committed
Merge branch 'refactor-states' of https://github.com/flixlix/power-flow-card-plus into refactor-states
2 parents 9457e49 + 3c64965 commit ab00be6

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/components/grid.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const gridElement = (
1919
? outageTarget
2020
: typeof entities.grid!.entity === "string"
2121
? entities.grid!.entity
22-
: entities.grid!.entity.production!;
22+
: entities.grid!.entity.consumption!;
2323
main.openDetails(e, target);
2424
}}
2525
@keyDown=${(e: { key: string; stopPropagation: () => void }) => {
@@ -30,7 +30,7 @@ export const gridElement = (
3030
? outageTarget
3131
: typeof entities.grid!.entity === "string"
3232
? entities.grid!.entity
33-
: entities.grid!.entity.production!;
33+
: entities.grid!.entity.consumption!;
3434
main.openDetails(e, target);
3535
}
3636
}}
@@ -67,7 +67,19 @@ export const gridElement = (
6767
grid.state.fromGrid !== null &&
6868
!grid.powerOutage.isOutage) ||
6969
(grid.powerOutage.isOutage && !!grid.powerOutage.entityGenerator)
70-
? html` <span class="consumption">
70+
? html` <span
71+
class="consumption"
72+
@click=${(e: { stopPropagation: () => void }) => {
73+
const target = typeof entities.grid!.entity === "string" ? entities.grid!.entity : entities.grid!.entity.consumption!;
74+
main.openDetails(e, target);
75+
}}
76+
@keyDown=${(e: { key: string; stopPropagation: () => void }) => {
77+
if (e.key === "Enter") {
78+
const target = typeof entities.grid!.entity === "string" ? entities.grid!.entity : entities.grid!.entity.consumption!;
79+
main.openDetails(e, target);
80+
}
81+
}}
82+
>
7183
<ha-icon class="small" .icon=${"mdi:arrow-right"}></ha-icon>${displayValue(main.hass, grid.state.fromGrid)}
7284
</span>`
7385
: ""}

src/power-flow-card-plus.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ export class PowerFlowCardPlus extends LitElement {
327327
}
328328
}
329329
solar.state.toHome = 0;
330-
} else if (battery.state.toBattery && battery.state.toBattery > 0) {
331-
grid.state.toBattery = battery.state.toBattery;
330+
} else {
331+
grid.state.toBattery = 0;
332332
}
333333
grid.state.toBattery = (grid.state.toBattery ?? 0) > largestGridBatteryTolerance ? grid.state.toBattery : 0;
334334

0 commit comments

Comments
 (0)