Energy Management in Home Assistant

Looks like you might be getting your wish according to the beta release notes there is a tool coming to correct long-term/historical data!

1 Like

This is ‘kinda’ easy:

p.s. I post on whirlpool too :slight_smile:

Hi,

I managed recently to connect to my power meter and can get many live updates into Home assistant and display these in lovelace, and this is great.

Now I tried to use the Energy Dashboard

I made customization to define device class, and state class for all used sensors like this:

sensor.kamstrup_l1_energy_total:
  last_reset: "1970-01-01T00:00:00+00:00"
  device_class: energy
  state_class: measurement

I also defined statistics sensors, like this:

 - platform: statistics
    name: kamstrup L1 total Stats
    entity_id: sensor.kamstrup_l1_energy_total
    state_characteristic: change

and succeeded to add these to the dashboard. So far so good.

But I observed that one energy source is showing the consumption but zero for the cost, and the other showing the cost but zero for consumption, and both are using same entity for variable price source.

Now (2 days later) the situation got even worse:
No consumption is viewed at all but the cost is still calculated:

Clicking on the empty graph of the individual devices, I also get the graph with historical data:

I noticed many of these warnings in my log and I guess these are related to the issue I have on the energy dashboard.

2022-04-03 09:28:03 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'sensorname' when rendering '{{ value_json.output.sensorname }}'
2022-04-03 09:28:03 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'energy_consumption' when rendering '{{ value_json.output.energy_consumption }}'

Any ideas, what I can do to find the reason for this issue and get it fixed?

@frenck I guess you know what’s going on behind the scenes, and hopefully can help :slight_smile:

Kind regards,
Ghassan

most likely because your inverter (what ever way you are getting the data from it) does send a value of ‘0 kWh’ instead of ‘unavailable’ every now and then though the statistics of the energy dashboard rely on it being an ever increasing value.

so let’s say it worked for 3 days and you produced 100kWh. now for some reason your inverter spits out ‘0 kWh’ that night, and the next value in the morning is 101 kWh - this suddenly gives you 201 kWh in your stats.

for sure it would be nice to have a way to easily correct such errors in the stats manually, but even better would be to make it less likely such erroneous values actually get in. which a. will hopefully be implemented in future versions (all this is quite early stages!) and b. can be done by routing the data via a template sensor.

it seems you have the same sensor defined for “grid consumption” and “return to grid” - as according to this image you are returning 5kWh to the grid though you’ve only produced 0.1

mind that you really need to have a sensor reading your export to get sensible stats - or you could use the powercalc addon to make a “virtual” sensor which is always zero if you don’t have a sensor and aren’t interested in the export (which seems likely with that little output).

I have similar issues. Now and then my solaredge communicates 0 as the lifetime energy. This happened yesterday from 22:00 till 07:30 this morning. The energy readings for yesterday show a huge negative value at 22:00, throwing out all readings. And this morning I have a plus of the same amount, also throwing out all readings. Can the software be adjusted to ignore 0 readings, then we won’t have this issue and a life time reading of 0 should be safe to ignore.

I think, as suggested above, you need to use a template sensor to remove the erroneous values before they get used. Look through this thread for template examples. This is a start Energy Management in Home Assistant - #109 by neives

1 Like

Is it safe to upgrade from 2022.2 to 2022.3?

I tried briefly when .3 came out, but my energy config was completely messed up. I found I had to switch from my “accumulated” statistics over to my standard energy statistics. I also found that it was doing odd things with my exports and imports.

I tried searching for it… not sure if it was just bad luck and the db was all messed up or if I missed a release note somewhere along the way.

I moved back to a backup and it was all OK again.

I want to combine/use the daily gas consumption over time with the daily outside temperature in a seperate histogram.
Is this possible ? How could I do this ?
I can not find any entity that contains the gas consumption over time to use as shown in the energy management dashboard.

Thanks

I managed to fix my issue that my enengy dashboard graphs were empty, and usage showd 0, by simply changing the state_class of all sensors from measurement to total_increasing

  • Is it officially announced that you should use total_increasing for sensors holding the total acumulated energy usage in order to be shown on the graph?

The issues i had with the many warning in my log, are still there, but does not effect the energy dash board.

1 Like

Just a small suggestion to the amazing energy dashboard team.
I would be awesome to have the individual devices included in the Energy Distribution Dashboard with their consumption showed, something like the attached MSPAINT example

1 Like

Isn’t your gas consumption an entity like any other?

Yes put it only gives me the cumulative value.
So it just goes up.

I’m looking for the consumption per day over a period.

You need to use metering helper so it creates a entity for usage per day

I don’t think it’s a “nice to have feature” but an essential one.

These erroneous data points (which I have not created - this is using the supplied integration) result in ruining the energy stats for that hour, day, week, month, year and all time. It renders the entire tracking of energy in HA useless. If it were my solar PV system doing it, then the other energy accumulation data systems I have would also display similar behaviour, but they don’t. It’s a bug unique to this HA Energy tab or the HA integration feeding it.

This is a monthly chart:

As you can see the few days with erroneous data make a mockery of the stats.

The annual chart so far:

Again it renders them useless. Jan & Feb actually had no erroneous data but you can’t see them register on the chart.

No, my home hasn’t generated and consumed 236MWh so far this year!

As to the cause of the bug, surely when the data being fed is an energy accumulation value which never ever goes down, then any number which is not already equal to or greater than the previous number should be ignored as erroneous. That’s how energy meters work, the energy accumulation register only ever moves in one direction.

See here for the new tool to fix this 2022.4: Groups! Groups! Groups! - Home Assistant

Hi,

Did you ever work this out? I have a new setup and see the same. I am in Sydney, Australia.

Cheers

Do you know where I can I find this or how it works ?

I don’t find any documentation of a metering helper…

hey mate yeah sorry

its now under Helpers now, so you dont have to use YAML

trust me - mine look way worse as i have not just one sensor acting up every now and then. and that’s why i say that correcting the symptoms of the root issue(s) shouldn’t be the goal here but measures to avoid getting such implausible data in there in the first place.

having to sit down checking/recalculating/correcting for every involved sensor every hour of a / every day wouldn’t make this feature much less useless than it is now…