Energy consumption miscalculated by Gosund EP2 or HA?

Hello HA team!

This is my first post. I am pretty new to HA, I have been fooling around for some months and whenever I can I try to learn something new.

Little description of my current “problem”:
I have several smart plugs Gosund EP2 flashed with Tamosta. Tasmota is sending watts consumption (among others) every 10 seconds to my HA through MQTT and it also sums the daily consumtion on its own. Until here everything is working just fine.

Until…

Today I decided to check the consumption of my washing machine, so I exported the data gathered by HA into excel, made some calculations and compared them with the data provided by Tasmota. To my surprise there are significant differences between both systems:

Lets explain the results with some details:

First image - Initially I saw the watts consumption through the graph provided in the history of HA:

Secong image - Then I exported the data from home-assistant_v2.db to excel and made the graph to see if they were the same (which they were):

Third image - Once in EXCEL I calculated kWh using three methods: mean kW x total time in hours, sum of W x time (10s) for every data point and finally the area under the curve with a trapezoidal approach. All three methods provided similar results with a value of 0,46 kWh (+/- 0,01 kWh).

Fourth image - If we compare the previous results with the provided by Tasmota with a value of 0,57 kWh, we can see that HA underestames by a 20% or rather Tasmota overestimates (Energy Today) by the same percentage.

Conclusions:

  • 20% is not a small misscalculation, it is rather significative.
  • This may happen because HA is receiving data every 10 seconds (Tasmota does not allow a smaller TelePeriod) and is loosing some data points?
  • On the other hand Tasmota is reading in “real time” and is more accurate?
  • Perhaps I made some mistakes or I am missing something?

I am really surprised with these results I was willing to read your opinions.

THANKS!!!

Federico (Argentinean living in Germany for 7 months).
PS: sorry for putting all the images together but I could not organize them in any other way because I am a new user.

1 Like

Nice write up and findings :+1:

Yes, rather significant. One thing to keep in mind is the type of plug you use is using a hlw8012 which is kind of the less accurate ones around (but probably the cheapest so the preferred one for manufactures). Still the 20% a probably do the rather low update frequency of 10 seconds.

Indeed, that will be actually very signficant. Just think about it the second tasmota sends data to mqtt (for example 100W) and the next second it raises to 1000W just to drop again to 100W before the next data point send.

The question is how much “real time” is real time? From my limited knowledge (didn’t use it in the recent years) tasmota doesn’t allow to change the interval of sensor polling (at least in a easy fashion).

Not sure if there is much left to tweak with tasmota. One thing you definitely could try is change *ware and throw esphome on your plug. You will then have not only the option to report values much more frequent to ha (and more efficient using the native api) but can at the same time influence the update frequency of the sensor :+1:

The template posted here (looks like compatible to your device) is using a 3 second update interval but obviously can changed to any value you want:

The esphome site features a little guide how to ota update from tasmota to esphome:

Hello @orange-assistant, thanks for your reply, nice words and recommendations.

I was thinking in putting ESPHOME to the plugs (I actually have an ESP8266 board with a DHT22, one IR receptor and one IR emitter to control some devices like: humidifier, tv, and “smart” vacuum).
I really like ESPHOME but I decided to use TASMOTA because I can set up the MQTT to use a domain, so I can take the plugs to different locations and get the information they collect.
Perhaps I can try ESPHOME in one of them and play a little bit to see how it behaves.

Talking about how to define the true values (Tasmota vs HA), I have finally found were my appartment has its own energy meter, so I could turn off all the circuit breakers and leave current only in one Tasmota and compare the provided values between them for a period of time. Unluckyly the meter is in another building and getting into it is kind of difficult (not imposible) so I will make an update in the future.

Thanks for your help, recommendations and links!!!

Federico

I expect you could do exactly the same with esphome because it has full mqtt support: :raised_hands:

And again a note on the hlw8012 (super) low budget energy monitoring devices: They need calibration (best for the load you plan to use) to give a acceptable output. :bar_chart: Here is a link to a over 3 year old blog write up explaining how it can be done :point_down:

I also heavily suggest to invest $10 in a pzem004t v3 which comes pre-calibrated and performs very very good for the price. It is a easy way to assure the calibration of other sockets turned out good (or bad).
Paired with a esp and esphome you can even set the update interval to 0.1 seconds to get extreme accurate readings (over time). :chart_with_upwards_trend:

Hey @orange-assistant!

I am using Tamosta in an outer network, each device connects to mydomain.com and is fowarded to my HA-supervised container within a RPi2. I have been fooling around with ESPHOME and did not find that option, I am even not using MQTT with ESPHOME because it is using its own API (not really sure, I am new in this HA world).

My 5 Gosund EP2 plugs have been all calibrated with a hair dryer and with an Uni-T multimeter.

REALLY NICE!!! I would love to have three of those!! Here in Germany all the house have 3 phase electricpower.

Does not your .db get too big? With 10 seconds interval my DB (sqllite) gets really big and the Rpi2 struggles to make the graphs and it is hanging lately, thay is why I am making my way into a Rpi4 with a 240 gg nvme ssd. Unlickyly my new deployment is having health issues and can´t install any add ons. Everything is difficult in Linux, I never find the easy way out :slight_smile:

Thanks one more time