Home Assistant release with the issue: 0.87.1
Last working Home Assistant release (if known): N/A
Operating environment (Hass.io/Docker/Windows/etc.): Hass.io
Component/platform: Utility meter
Description of problem: I have a miner connected to a Xiaomi smart plug that measures the consumption of it. It usually consumes about 540 Watts, however when it hangs the consumption goes down to ~100-120 Watts, when that happens I power cycle the Xiaomi smart plug, but after that the Utility meter shows irraneous measurements:

The first value is the current consumtion, the second is the Peak monthly counter and the last one is the off-peak monthly counter. Usually the peak counter is twice the count of the off-peak, but this morning the counter went crazy.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
#Utility meter
utility_meter:
energy:
source: sensor.miner_consumption_current
cycle: monthly
tariffs:
- day
- night
Automation:
- id: '1550064608948'
alias: '[Utility] Tariff switch'
trigger:
- at: '23:00:00'
platform: time
- at: 07:00:00
platform: time
condition: []
action:
- data:
entity_id: utility_meter.energy
service: utility_meter.next_tariff
Traceback (if applicable):
Additional information:
sensor.miner_consumption_current provides information in kWh or W ?
It provides the information in W, but the Utility meter counts the kWh. I don't do any conversions it is by default (I just customized the unit of measurement):

I noticed the same behavior today as well. It all works well until there is a spike in the consumption (e.g. the miner restarts and the consumtion drops):



Ok, so here is the deal:
To do that you can use the integration sensor:
https://www.home-assistant.io/components/sensor.integration/#energy
You then use this new sensor as the source for the utility_meter
I see, thanks. However, why is the off-peak counter working without any conversion - the sensor for the miner provides W (500 Watts moment consumption) and the utility meter counts kWh (e.g. for one hour it counts 0.5 kWh) and it also works the same for peak hours, unless there is a spike in the consumption.
That was just me thinking out loud, maybe there is something in the backend that I don't see and wanted to understand it.
Thanks though, I will update my config.
The utility meter is a sum of the differences of the source.
Basically gets the current measure of the source, subtracts the previous measure, and adds up to counter (which is what is displayed). I think your "right" values are sheer luck ;)
@dgomes LOL, makes sense now :)
Most helpful comment
Ok, so here is the deal:
To do that you can use the integration sensor:
https://www.home-assistant.io/components/sensor.integration/#energy
You then use this new sensor as the source for the utility_meter