Reset entity energy power every mounth

Hi, I create a template sensor in this way to monitor energy in KWH:

sensor:
  - platform: integration
    source: sensor.power_in
    name: Energy_in
    round: 2

now every mounth I want to reset to 0 this value, so I use a pyscript like this:

  - service: python_script.set_state
    data:
      entity_id: sensor.energy_in
      state: 0

and it works, but as soon as the energy is updated by template/integration it returns to old value.
Should I restart HA as soon as I reset ? Is there a trick? thanks!

Use the Utility Meter with a monthly cycle to monitor your sensor.energy_in.
It will reset automatically on a monthly cycle for you.

Also with the integral sensor make sure you have the method set correctly or it will accumulate large errors:

The default trapezoidal method should only be used if your power sensor changes very smoothly. If your power switches on/off (squarewave-ish) then make sure to specify the left method.

1 Like

Ok thanks I modify energy calculator, and created 2 more entity that will reset automatically… next mounth I hope :slight_smile: