Solar and house consumption incorrect, and how to add a battery

I installed and setup HA about a week ago, so very new to this.

I’m presuming the energy dashboard should show daily figures, the grid figures are correct, but solar generation and the home consumption figures are wrong.


I’ve noticed I have solar production in the early hours of the morning, also energy consumption.

Solar Production Energy Usage

These are the settings.

Electricity import and export come from a Glow CAD IHD via utility meter helpers IIRC.

Victron (Total Yield Today) comes from my Victron PV system, this resets at midnight, although I do need to confirm this (it seems it doesn’t - see note below). The value is obtained via MQTT which connects to Node Red on my Victron system.

    - name: "Victron (Total yield today)"
      unique_id: "victron_total_yield_today"
      state_topic: "TotalGenerationToday"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      icon: "mdi:solar-power"

I also have a battery (which is probably confusing things), but I can’t figure out what information to add, the More information on how to get started. is not helpful in my case, it doesn’t really tell me anything remotely useful. Clicking “ADD BATTERY SYSTEM” states it wants kWh in and out of the battery. I’ve not come across a kWh in and out of the battery figure, so can’t at the moment add this. Now I know the battery voltage, and I know the current flowing, also consumed ah so presumably somehow I can calculate the kWh, but no idea how to go about this.

Any thoughts please?

Edit: Just checked the Victron system, and the solar yield from the MPPT charge controllers does not reset at midnight, so not sure when it does reset - so need to figure that one out.

I don’t have solar/battery systems, but if you have voltage(Volts) and current(Amps) reporting, multiply them to get power (Watts). You can do this in a template sensor.
if you have Ah from battery, multiply by Volts to get Wh. Divide by 1000 to get kWh
Look up ohms law for any other equations.

@rwoelk Thanks for the reply.

I have Ah consumed, I have Watts as well, I have voltage, but the information on the help page doesn’t explain what HA is expecting to to see, or how it uses that information, which would help me understand what is required.

HA wants two value’s:

  • Energy going into the battery
  • Energy coming out of the battery

It’s asking for those values in GJ, kWh, MJ, MWh, or Wh.

Its a 280 Ah battery, so if we’ve consumed 100Ah at 50v then that’s 5kWh, but as we consume Ah the voltage drops, so not sure how to factor that in, or whether to just use the middle of the range, or an average voltage.

The above gives us one figure, but HA is asking for two, so what are these two?

Annoyingly Victron does have a node for Charged energy (kWh), and another for Discharged energy (kWh) which on the face of it appears to be what HA wants, but alas the Victron system doesn’t give any values.

I have now added sensors for Charged energy (kWh), and another for Discharged energy (kWh), but the energy dashboard still thinks I’m generating solar between midnight and 1am.

The sensor for the solar yield is reset at midnight, and the graph for the sensor reflects this, so why does HA think I’m generating solar at midnight?

It has the wrong values for solar production for the day, and also home consumption.

Its calculating home consumption, so until solar production is correct, home consumptions won’t be correct.

Any ideas?

Just to update on this, I have several arrays, and one was not resetting until 00:01, the other two are 15 & 25 seconds past midnight, and it seems that HA has no leeway what so ever, so anything reported after midnight, even by 15 seconds is counted as the new days production.

I need to modify my Victron code to reset at 23:59 and see if that cures it.

Look at the specs for your battery. There should be various voltages applicable, depending on whether the battery is being charged or discharged. I can’t speak for Victron, but on Sunsynk these are actually set on the inverter (according to the battery specs). Either way, something close enough is probably good enough for practical purposes.

Does your Ah sensor go both positive and negative, or do you have two sensors? Regardless, you can make two energy template sensors from that: one for battery energy consumed and one for produced. Look at the energy flow card in HA: that’s why it wants it.

@parautenbach Thanks for you’re reply, as per my reply a couple of days I’ve now fixed that part, think I have the rest sussed as well.

The Victron system gives voltage and amps roughly every five seconds, so I calculate the kWh per five seconds (I actually measure the exact interval and calculate based on that), and if negative then its added to the daily discharged value, and if positive, then its added to the daily charged value. Not perfect but close enough.

1 Like

Finally HA reports the correct solar generation, and therefore also house consumption this morning.

It seems that HA is super fussy, and does not handle poor timing at all.

When you add solar production it states

Pick a sensor which measures solar energy production in either of GJ, kWh, MJ, MWh, Wh

So we are adding generation over time, it does not mention what that time period will be, minutes, hours, day???

It then states.

Adding solar production forecast information will allow you to quickly see your expected production for today.

So we presume its daily, most systems will produce a daily total in kWh, so we use that.

But HA falls over if that total is reported even a few seconds past midnight, if my sensor say 25 kWh at 15 seconds past midnight, then that sensors says 0 at 30 seconds past midnight the dumb HA system assumes I generated 25kWh in thirty seconds rather than resetting to zero!

What I had to do was ensure that all three of my arrays report zero from 23:59, this is then summed to a daily yield in Victron Node Red and then broadcast via MQTT.

I wonder just how many other system don’t have impeccable time keeping, and therefore HA ends up with the wrong values.

PS. Somewhere preferably with a link from within the Energy Dashboard setup there needs to be a good explanation of exactly what information it requires, and how that information is used. I had to guess for the battery data, and then spend some time working out what was causing the erratic solar generation figures and house consumption figures.

Well done on getting it sorted.

The energy dashboard ‘expects’ energy meters - meters that just count up as energy is used - the way your house electricity meter used for billing works. The energy dashboard does the daily, weekly etc totals. That way the energy dashboard can show live data during the day as things vary.

With ‘count up’ meters the update period is irrelevant as is exactly when they change.

1 Like

Thanks, I can see how that would solve the midnight timing problem, shame it wasn’t stated when I set up the energy dashboard.

I could supply the total generation from all arrays, but I have the sneaky suspicion that HA will think I’ve generated circa 32,000kWh in one go :rofl:

I’m going to have to change it to overall total generation as @steve_jo said, Victron still sometime shows yesterday yield even between 4am and 5am, so HA thinks I’ve generated a chunk very early morning.

I’ll take the hit on one days data being off, but I’ve no idea how that will affect reporting going forward, it would be nice if there was an easy was to reset the energy dashboards data.