Energy Management in Home Assistant

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

I have posted a new topic in community forum to suggest to add Water Heating as new source/consumption of energy on the top of Grid, Solar and Gas, for those who are connected to district heating or have solar water panel.
I am not speaking about water consumption…
see Add Water Heating as source of Energy

Cheers

1 Like

Hi such a problem and I can not find a solution
database - mariadb.
1.After restart, HA added the entire value of the entity to me, not just the measured hour. How to avoid it, is there a way?
2. Is it possible to remove this result from the database so as not to disturb the whole?

There is a nice topic about this.

1 Like

Hello,
I am struggling to monitor energy in KWh from Tuya wifi plug with energy monitor.

Home Assistant recognize the value of the plug without problem:

tuya switch

So I created this sensor to convert the value of “Power (W)” in KWh:

- platform: integration
  source: sensor.fridge_power
  name: KWh Fridge
  unit_prefix: k
  unit_time: h
  round: 2

Then I personalized the entity adding two custom field: state_class and last_reset.

In the developers tools it looks like this:

state_class: measurement
source: sensor.frigo_power
unit_of_measurement: kWh
friendly_name: KWh Fridge
icon: mdi:chart-histogram
device_class: energy
last_reset: '2000-01-01T00:00:00'

The problem is that I saw the entity in “Energy Monitor” on Home Assistant but with wrong value because it shows me a daily consumption of 3 KWh instead on Smart Life app I saw a daily consumption of 0.54 KWh.

I tried to convert by myself the value of the watt in kwh and HA is 100% wrong. Even if I add “method: left” or “method: right” nothing changed.

What am I doing wrong ?

Thanks.

2 Likes