Resetting counters with an automation doesn't work

Hi,

I’m trying to get HA to show me how much energy is left in my batteries which are connected to my solar panels. I therefore created two helpers. One is tracking the energy flow TO the battery and the other one the flow OUT of the battery. I then created a template sensor that subtracts the second value from the first one. I also multiply the first value by 0,917, because that is roughly the overall efficiency from the panels to the grid.

As all of this isn’t perfectly accurate, I want to reset the value from time to time and I thought the time when the battery is “empty” is pefect for that. So a new cycle should start, whenever the battery reaches the lower voltage threshold and the micro-inverter stops drawing energy from the battery. I wrote an automation for that purpose, but it doesn’t work at all. The counters are not resetting.

The template sensor for the calculation looks like this:

template:
  - sensor:
      - name: "Energie im Akku"
        unique_id: "energie_im_akku"
        unit_of_measurement: "kWh"
        state_class: "total"
        state: >
          {{ states('sensor.akku_einspeisung')|float(0) | multiply(0.917) - states('sensor.akkuentnahme')|float(0) }}

And this is the automation:

alias: Akkuladezustand Reset
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.shelly_plus_plug_s_switch_0_power
    for:
      hours: 0
      minutes: 30
      seconds: 0
    below: 2
condition: []
action:
  - service: utility_meter.reset
    target:
      entity_id:
        - sensor.akku_einspeisung
        - sensor.akkuentnahme
    metadata: {}
    data: {}
mode: single

Any idea what i need to change?

Your title is misleading. There are no counters involved in this. Utility meters and counters are different things.

You can’t reset utility meters that do not have tariffs.

You can however calibrate them to 0.

action:
  - service: utility_meter.calibrate
    target:
      entity_id:
        - sensor.akku_einspeisung
        - sensor.akkuentnahme
    data:
      value: 0

Oh, thanks for pointing that out. That confusion may be due to my HA being in German, where both are called counters.
I‘ll try the calibration.