Trying to create simple energy overviews for a smart plug

I’ve had a good look through the existing posts, but none of them appear to offer a solution to what I need.

I have a simple smart plug (Ikea Inspelning) that has a Wattage entity. I was hoping I’d be able to setup a few simple cards for my HA dashboard showing the below, but I cannot seem to figure this out;

Usage for current hour so far (kWh / £x.xx)
Used previous hour (kWh / £x.xx)

Usage for current day so far (kWh / £x.xx)
Used yesterday (kWh / £x.xx)

Usage for current month so far (kWh / £x.xx)
Used previous month (kWh / £x.xx)

I had assumed this would be a simple setup as I have a fixed tariff - Create helper for tariff value… create helper to calculate/track W to kWh… create helpers for above calculations… add new sensors to cards.

Can I figure this out? Nope.

Has anyone done this? Do I really need to go through the Energy dashboard for part of this? I’ve not grabbed myself a utility meter device to monitor the entire home energy usage… yet.

So you only have power sensors (W) and no energy sensors (Wh or kWh)?

Correct. There is a “summation delivered”, which I’m assuming is kWh, but it’s just a raw number.
That one popped up after it received a firmware update last night.

Did you try to set up utility meter ?

Yes, but it just gives me the same number-only reading as the default summation when I point it to that entity (albeit starting from zero). Still no wH to use against any calculations.

Feed your power sensor to the integral helper to get energy. Pay particular attention to the method option. You most likely want left to reduce approximation errors.

Then feed that energy sensor to utility meter helpers with hourly, daily and monthly cycles.

Is that not a bit of a fudge? I tried this already and, although it spits out an energy value, it’s different to that of the “summation delivered” directly from the plug sensor, which I assume it accurate.
I would expect the integral calculation to match that of the summation if it was accurate.

Did you use method: left ?

Trapezoidal is no good for on/off waveforms. However, lets fix your summation sensor instead.

Why does your plug not have the correct unit and class for the energy summation sensor?

How is this integrated into home assistant?

Thanks for your help so far - I have a small update; After a reboot of Home Assistant, the Summation Delivered sensor is now reporting an actual kWh unit of measurement!

So, at least that part can get put to bed, I just need to work out how to marry this up with my fixed tariff then try and get a coupe of cards created :slight_smile:

… but it doesn’t show as a value to chose for the Energy Dashboard. Just a few “ghost” entities from my previous testing :sob:

Go to Settings → Devices & Services → Entities. Sort by the last column “Status”. Delete the “ghost” entities.

Go to Developer Tools → Statistics. Fix all listed issues.

Go to Developer Tools → States. Find your energy sensor and look in the right hand attributes column. What does it say?

Ghost entities deleted. Thanks for the tip.
All listed issues fixed.

Attributes:
status: NO_ALARMS
friendly_name: Homelab smart plug Summation delivered

I managed to get this to have the correct kWh unit previously. I only rebooted HA for this to report a changed unit of measurement.
I removed the plug from HA and re-paired it, but it’s showing no unit against the summation again.

Not sure how to “force” it back to kWh.

The plot thickens.
Another reboot and now it’s showing the correct kWh unit. The reading is way too high now, so I’m expecting to be prompted to “fix” this and delete the historic date shortly.

I don’t understand it at all.

And just like magic…

To be used in the energy dashboard it needs:

unit_of_measurement: kWh # or Wh
state_class: total # or total_increasing
device_class: energy

So all good now?

According to the attributes, yep. However, the multiplication is still incorrect. it appears to be sending Wh but showing as kWh, so I’m getting a use of 29 kWh in the past 5 minutes, which is a little… extreme.

I’m hoping it’ll have another “settling”, start recording correctly and prompt me to delete the inflated values again.

If all this falls into place I’ll still need to return to my original task of creating day, week and month rolling readings.

Click on the cog icon in the pop-up card. Change the unit to Wh.

I think that broke it :frowning:

Oh. Wrong way, sorry. Change it back.

If I change it back, it just reports wH as kWh again. Must be changing the multiplication in the background too.
It’s clearly ticking up in wH, but changing it to the kWh unit just multiplies it all by 1,000.

Frustrating.

I appreciate this isn’t your problem, so your support and suggestions so far have been more than welcome. Thank you.