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

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

Open
ulic75 opened this issue Nov 11, 2022 Discussed in #108 · 8 comments
Labels
bug Something isn't working

Comments

@ulic75
Copy link
Owner

ulic75 commented Nov 11, 2022

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?

@ulic75 ulic75 added the bug Something isn't working label Nov 11, 2022
@steelixb
Copy link

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.

@CrazyHenk44
Copy link

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.

@ulic75
Copy link
Owner Author

ulic75 commented Jun 27, 2023

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

@CrazyHenk44
Copy link

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.

@ulic75
Copy link
Owner Author

ulic75 commented Jun 27, 2023

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.

@CrazyHenk44
Copy link

Yeah, of course. Thats the default answer nowadays.

@jensuffhaus
Copy link

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.

@steelixb
Copy link

steelixb commented Jun 28, 2023

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants