Electric meter index update with the total consumption sensor

Hi
I’m searching for a solution to update my electric meter.

I have a shelly EM which is reading the energy consumption. (sensor.energy_total = 34.54Kwh)
and i have the index from the energy meter 12345 (input_number.energy).

I would like to have a sensor which calculates the index of meter. Curent index + consumption (12345+34.54)
I tried with this automation:

alias: Update Energy Meter
description: ''
trigger:
  - platform: time_pattern
    minutes: '*'
condition: []
action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.energy
      value: >-
        {{ states('input_enenrgy.energy')|float +
        states('sensor.total_energy')|float }}
mode: single

but it always get the value of shelly sensor.

Hi, why not to create template sensor:

sensor:
  - platform: template
    sensors:
      energy_total:
        value_template: "{{ states('input_enenrgy.energy')|float + states('sensor.total_energy')|float }}"
        device_class: energy
        unit_of_measurement: 'kWh'
        friendly_name: Energy total

There is a service to calibrate the utility meter integration. The only issue with that is that it will reset every year at the least.

Thank you!
I created a template sensor. It seems to work!

Also worked with calibrate service