Manually update last_reset attribute (daily)

As probably a few of you have done after the Energy panel integration in home assistant, I forced the missing attributes to some of my sensors in order to see them in the Energy .

customization.yaml

# Reading of total energy of the house (always incrementing)
sensor.tasmota_energy_meter_energy_total:
  device_class: energy
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'

# Reading of total energy used by Device A today (since midnight)
sensor.tasmota_energy_meter_DeviceA_today:
  device_class: energy
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'

Although I don’t care much about the last_reset time of the first sensor (being a always incrementing number, a sort of “absolute”), I do care a lot about the last_reset time of the second one, being reset to 0 every day at midnight.
I’m looking for a solution here that would allow me to manually change the last_reset time (every day at midnight).

I think this guy had an interesting thought but that’s still not a good solution:
How to update trigger templates correct - Configuration - Home Assistant Community (home-assistant.io)

In a nutshell, how can I modify an attribute while HA is running?
Maybe there is a way to add the last_reset directly to the mqtt message I receive from the tasmota device?

last_reset attribute have been deprecated in 2021.9 and will be removed in 2021.10 i believe. Please see the latest update for the alternative state_class = total_increasing

Oh, alright…

I just updated my customization.yaml in the following way

sensor.tasmota_energy_meter_energy_total:
  device_class: energy
  state_class: total_increasing

sensor.tasmota_energy_meter_energy_DeviceA_today:
  device_class: energy
  state_class: total_increasing

Staying at what this article (Sensor Entity | Home Assistant Developer Docs) says, it should fix my issue on it’s own now. Whenever it sees a value lower than the previous one it interprets it as a new value of a new cycle, did I get this right?

Yeah i believe so :smiley: total_increasing replaces the use of last_reset with measurement

2 Likes