ulic75/power-flow-card

Should I be seeing a dot moving from grid to battery when charging my battery from the grid?

Opened this issue · 8 comments

Discussed in #108

Originally posted by derekyle November 11, 2022
I don't have solar panels, so I charge my battery from the grid and use it during peak power. Everything seems to be working with this card except there is no dot moving from grid to battery even though the battery shows the correct kW for power coming in or out. Is that simply a limitation of the card or do I have something setup wrong?

Seeing the same issue. Also seems to include battery consumption in house consumption when charging. I see the same problem with the original card too.

Yes, this is confusing. I expected a moving dot from grid to battery for the part that is charging. Played with the settings to fix it, but concluded eveything was setup correctly in this card.

Is there a value for grid production? In the below picture Grid Production is 4kW, battery consumption is 3kW, meaning home is consuming 1kW. Obviously you can't see the dots move, but they are both moving from grid to home and batter.

image

Safari My Energy – Home Assistant 21 50 24@2x

In this case, i would expect that home says 400w, battery 500w and grid 900w and a white dot running from grid to battery.

Ha, should have read my own comment in the discussion. It's an issue when in this situation and there is no solar. PR would be welcome.

Yeah, of course. Thats the default answer nowadays.

image

I am also seeing this and just wondering if this is going to be fixed in this card or if it is something deeper inside HA that needs fixing.

I did get the correct number showing on the "Home" circle by using the "Override State" option. Without that "Home" just inherits the "Grid" value.

I haven't had a chance to test this yet within this card, but this code should fix it:

const totalHomeConsumption = ((totalBatteryOut ?? 0) - (totalBatteryIn ?? 0)) + ((totalFromGrid ?? 0) - (totalToGrid ?? 0)) + totalSolarProduction;

let solarToBattery: null | number = null;
let solarConsumption: null | number = null;
let solarToGrid = 0;

if (hasSolarProduction) {
  solarToBattery = Math.min(Math.max(0, totalBatteryIn ?? 0), totalSolarProduction);
  solarConsumption = Math.min(totalSolarProduction - solarToBattery, totalHomeConsumption);
  solarToGrid = totalSolarProduction - solarConsumption - solarToBattery;
}

let batteryFromGrid: null | number = null;
let batteryToGrid: null | number = null;
let batteryConsumption: number = 0;

if (hasBattery) {
  batteryConsumption = Math.min(totalBatteryOut!, totalHomeConsumption - (solarConsumption ?? 0));
  batteryToGrid = totalBatteryOut! + (solarToBattery ?? 0) - batteryConsumption;
  batteryFromGrid = Math.max(-batteryToGrid, 0);
  batteryToGrid = Math.max(batteryToGrid, 0);
}

const gridConsumption = totalHomeConsumption - (solarConsumption ?? 0) - batteryConsumption;