Energy Management in Home Assistant

There was debate a few months ago about this.
From memory the concensus was that water is not energy, so no.

since the focus is on “Energy” Usage - I do agree.
And I think, at the moment, the energy section does still have much space for improvements… :slight_smile:

Long Term, I would love to see the Energy Dashboard evolve to a “Environmental Impact” Dashboard, which does also integrate methods for Water usage and other possible measurements… :slight_smile:

1 Like

Yes short term evolution are:

  • have addition between electricity energy and gas energy (in kWh)
  • have a new calculation of non fossil percentage taking into account gas (definitively fossil)
    There is PR ongoing that is not yet accepted
    Phil
1 Like

I was struggling with this for a long time so thanks for the pointer. I’m using an EmonPi which supplies float value for the Wattage, so this worked a treat for me…

- platform: mqtt
  name: "Garage Electric"
  state_topic: "emon/emontx/power3"
  device_class: power
  unit_of_measurement: "W"
  value_template: "{{ value | round(0,half,0) }}"
- platform: integration
  source: sensor.garage_electric
  name: Garage Electric kWh
  unit_prefix: k
  round: 2
1 Like

If you haven’t figured it out yet, this post (not mine) worked for me and saved me a load of time:

Hi everyone, I hope I don’t post in the wrong place with this question. I have a Frient/Develco electricity meter that works very well. It reads consumption from my semi-smart energy meter that the elecrical company uses to bill me. A very nice guy just helped me to show the instantaneous power being pulled (in W) and also to make a counter that shows total minutes the power has been over a certain threshold.

What I hope to achieve is to measure the consumption in kWh of my dumb heater. I know it draws 6000W when it switches on, so I want to use this for mapping the total consumption per day/week/month/year. Figure I should use a helper, counter, template sensor or whatnot… I searched the forums, documents and search engines but I can’t figure it out. I don’t have a really good knowledge of HA yet.

Something like: “Heater switches on (power being pulled suddenly increases with 5900W) → some sensor starts reading and recording this → translates the W to kWh → sends this to the UI of HA.”

Ideally it should be the actual W being read by the smart meter, but it could also be: "Power being pulled suddenly increases with 5900W → some sensor starts reading and recording this → the sensor is using the time between the increase and when it decreases with 5900W → translates the data to kWh, given that a full hour of “increased power” is 6kWh.

It would be very very good to get this into the “official” energy dashboard, but might not be possible atm…?

I think this solution could benefit a lot of people who want to brake down total household energy usage to separate devices. Some devices are permanently installed and can’t be put in one of the various existing smart plugs, and not so rarely it’s the “heavy consumers”. So if one knows the power that their device is pulling when active, one could use this solution to measure its consumption. As long as one does not have several devices that pull about the same energy when used that is.

Would appreciate some help here!

I use hassoss core-2021.10.6, HA 6.5, on a Rpi. Deconz for zigbee.!

Esentially, it’s the spikes on this I want to measure expressed in kWh used:

power|387x341

you have one major issue with your idea.
The meter, which is measuring the total usage of your household cannot be used to measure single devices.

Just imagine the following situation:

your meter is constantly measuring the energy usage of your household.
If you switch your heater on - the energy usage will be increase by x watt… but what happens, if another device will be switched on - or something will be switched off at the same time.

just going for a fix amount of increased power usage does not really help getting reliable information.

Thanks for your reply! @CChris

The meter is ofc not able to measure single devices by default. But i’m thinking it perhaps could be made “good enough” in some situations.

As for reliability/accuracy, if this could be done, it would get reliable enough information, atleast for me and surely for other ppl with about the same household setup as me. Ie few individual devices that constantly draws the same amount of power when switched on, and if that power is fairly large (6kW in my case).

I agree that if the sensor (or what might work best) starts to measure and “record” the energy usage if it’s increased by a certain W, also will “get” any eventual devices that are switched on after the one you want to measure. That might be counter measured in code or by some other magic I’ve seen users here do. But if not, thats where my thought came in of using “time between power usage in W increased by X amount until it decreased by X amount” and then translate it into kWh.

You don’t think it can be done?

Yes I would suggest you look at the Powercalc custom component.

I would create a binary sensor heater_on and then create an automation that flips that to true when your consumption goes over 6000W.

Then you would set up Powercalc with your binary sensor and use a manual power setting of 6000W. Powercalc will then do everything you need (and probably more!)

Of course if anything else puts your consumption over 6000W then you will have inaccuracies….

1 Like

How can I delete data from the Energy Dashboard?

I accidentally added the total grid use sensor as single device. Even after having deleted it from that section, all graphs and statistics still fail, everything is rendered useless :frowning:

Update: solved with/in Energy Management in Home Assistant - #1127 by e-raser.

Anyone else have issues adding an Iotawatt calculated output to the Energy dashboard?

I created the outputs as described in the official HA docs but HA won’t let me add the accumulated Wh entities. As far as I know they have the correct attributes.

The only thing different I see compared to mine is yours has Type: Output but mine has Type: Input

That’s just because my example entity above is a calculated output from the iotawatt rather than one of the hard-wired inputs.

Input example:

One thing I’m thinking though is that my entities are in Wh rather than kWh… It seems the Energy dashboard might only accept kWh? Even though the HA docs don’t say we need to create a conversion for the iotawatt sensors.

image

No I found this one that appears in the drop down list of the energy configuration. I have lots that are Wh

image

Well then I have no idea why I can’t add any of the iotawatt entities to the Energy dashboard then. It’s odd because I’ve simply followed the HA docs… It was easier using the custom component :thinking:

Yeah not sure sorry. Im not using the offical add-on… Maybe try the Iotawatt thread as you did before?

Yeah, I just didn’t want to spam it too much with issues relating to the core integration since that thread is for the custom one. Will try anyway

Is there a way to manually correct the data on Energy Management? I had some networks issues yesterday and my Shelly EM3 was offline and came online one yesterday and twice this morning. So my daily, weekly and monthly are quite a bit off now. See the screens:

Day before yesterday, when everything was ok:

Yesterday:

Today:

I would be ok, if i can delete those two spikes and no data for those two days.

2 Likes

Turned out it was caused by Shelly EM3. After restar sometimes it will be unavailable and because of that calculation that sums three phases will be 0 for a brief moment and then back to where it really was. Trick was to add availability_template to the template sensor. More here: Shelly 3EM 3-phases Energy sensor - #56 by arva

But now i need to delete those spikes and I don’t know where.

EDIT: Here is a solution how you can delete from the DB: Energy Management in Home Assistant - #455 by markss

4 Likes

Thanks for sharing the instructions!

My issue was that Shelly EM was unavailable few times after restarts and template sensor that sums up three phases went to 0 and theb back to real value.

When i investigated database with SQLite Web I saw the problem with some 0 rows and sum lines that were affected. I deleted the 0 rows and corrected the SUM values with UPDATE. Now everything in DB looks good, but Energy Dashboard still shows the wrong numbers.

Any ideas, where the Energy Management gets the (wrong) data?

EDIT: If anyone is using HA in a Docker stack, SQLite Web works neatly with Docker Compose:

  sqliteweb:
    image: tomdesinto/sqliteweb
    ports:
      - 8089:8080
    volumes:
    - ${USERDIR}/docker/homeassistant/home-assistant_v2.db:/db/home-assistant_v2.db
    command: home-assistant_v2.db    
3 Likes