How to use utility_meter and integrations to summarize my energy and mileage?

I have a sensor named sensor.tesla_charge_energy_added_kahless, and I want show my charge energe from daily, monthly and yearly.

Then I test it like following code:

utility_meter:
    monthly_charge:
        name: kahless_tesla_charge_energy_monthly
        source: sensor.tesla_charge_energy_added_kahless
        cycle: monthly

value changes from mqtt:

UI display:

It shows the utility_meter only calculates the difference, that’s now what I want.

And also integrations cannot set start and end time.

Cannot get the right answer in Chinese community, so I’m here to ask help, can anyone show me the right way? thx a lot

Following table is exactly what I want,but I cannot make the correct values:

up…up… dont sink

I think we are losing something in translation because the utility_meter integration should do exactly what you wants and store the value in the designated cycle: daily, monthly, yearly. Can you be more specific as to what it isn’t doing for you?

ok, I can make a new example to describe what I configured and what I really want, wait a second

@mboarman

I’ve created a new sensor in mqtt_sensor.yaml, which means I can send the value from my mqtt client:

 - name: mboarman_ev_energy_added
   state_topic: "teslamate/cars/1/mboarman_ev_energy_added"
   device_class: energy
   unit_of_measurement: kWh
   icon: mdi:battery-charging

and two utility meters:

 mboarman_ev_energy_added_hourly:
   name: mboarman energy hourly
   source: sensor.mboarman_ev_energy_added
   cycle: hourly
   
 mboarman_ev_energy_added_daily:
   name: mboarman energy daily
   source: sensor.mboarman_ev_energy_added
   cycle: daily

Then I published 1 and 2 and 3 in 8:00 AM:

Now I can see them in UI:

type: glance
entities:
  - entity: sensor.mboarman_energy_hourly
    name: Utility Meter Hourly
  - entity: sensor.mboarman_energy_daily
    name: Utility Meter Daily

However, the value of utility meters are not correct based on source value.
“Utility Meter Hourly” should be 1+2+3=6, not 2 kWh displayed in UI;
“Utility Meter Daily” should also be 6 (should not be 2kWh), and it will be the sum of today’s values, am I right?

After 5 hours I’ve tested it again, I published 5 and 6 and 7 this time from mqtt in 13:00,

I think the “Utility Meter Hourly” should be 5+6+7=18,
and “Utility Meter Daily” should be 1+2+3+5+6+7=24.

However, “Utility Meter Hourly” is 4 and “Utility Meter Daily” is 6, and this makes me very confused


Nope. 1 changing to 2 is 1kWh then 2 changing to 3 is 1kWh. 1+1 = 2kWh.

That is the way the utility meter counts by default. So 899 → 903 = 4kWh, not 1802kWh (899+903).

If your sensor reports delta values rather than a running total you have to tell the utility meter that in your config. Like this:

mboarman_ev_energy_added_hourly:
  name: mboarman energy hourly
  source: sensor.mboarman_ev_energy_added
  cycle: hourly
  delta_values: true
   
mboarman_ev_energy_added_daily:
  name: mboarman energy daily
  source: sensor.mboarman_ev_energy_added
  cycle: daily
  delta_values: true

woooooow, delta_values fixed my problem, thank you soooooo much
I should read the doc more carefully, thanks again

1 Like

@tom_l
Hi Tom bro, I found another question
In my real scenario, the value of sensor pulished from tesla,
and it changes about every 40 seconds in one charge period, like from 0 to 42kWh
and it’ll reset to 0 in the beginning of next charge period, change from 0 to xx kWh again

So, I tested delta_values cannot solve this perfectly, could you please take a look?

I have no idea what you are asking. There is no need to tag me in every reply, I am following this topic automatically as I have posted in it.

sure,thanks anyway