Utility Meter value adds current daily value upon each hassio restart

Hi,
I was able to get active daily time “on” from tasmota using history stats.
code:

  • platform: history_stats
    name: Oil burner active time
    entity_id: switch.senzor1_temp_vlaz
    state: ‘on’
    type: time
    start: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    end: ‘{{ now() }}’

I have converted time to liters using this code:

  • platform: template
    sensors:
    oil_consumed:
    value_template: ‘{{ ((states.sensor.oil_burner_active_time.state | float * 2.6)) | round(2) }}’
    friendly_name: ‘Porabljeno’
    unit_of_measurement: ‘L’

When I use utility meter, everything works well:
code:

monthly_oil:
source: sensor.oil_consumed
cycle: monthly

…unitl I restart the hassio.

Then the value of sensor.oil_consumed gets added to sensor.monthly_oil

Example:
values before hassio restart:
sensor.oil_consumed = 0.5 L
sensor.monthly_oil = 1.0 L

values immediately after hassio restart:
sensor.oil_consumed = 0.5 L
sensor.monthly_oil = 1.5 L (it falsely adds 0,5 L, which it should not do)

And for each restart “sensor.oil_consumed” is falsely added to “sensor.monthly_oil”.

What am I doing wrong?

Does sensor.oil_burner_active_time time survive the restart with the same value?

If it does, I’d replace the oil consumed template with this:

value_template: "{{ (states('sensor.oil_burner_active_time')|float * 2.6)|round(2) }}"

This will not error if sensor.oil_burner_active_time is unavailable until shortly after the restart.

Yes, it does survive. I’ll try your advice. Thank you.

Update after change and hassio restart:

sensor.oil_burner_active_time: value OK.
sensor.oil_consumed: value OK.

“sensor.monthly_oil” : not OK. Still gets extra added value from “sensor.oil_consumed” after hassio restart.

Hi there mmatesic - Did you ever manage to resolve this issue? If so, could you tell me how as I have exactly the same problem on a restart.

Many thanks

1 Like

Hi. I just gave up,since it did not give me result.

I’m having this issue too!

1 Like

Hey guys

I’m having this issue too.
Did one of you have an idea?

Thx