Need help creating a template sensor energy meter

Hi,

Is there anyone who could help me with the following question.

I have a Qubino Z wave energy meter for some reason when the sun is down and my panel inverters go into standby mode the current wattage raises to 1.677.720,6 watts. The meter works fine during the day so no issue there. The kwh value stays the same so that is working also fine.

Without discussion what the reason could be I want to create a template sensor in my config file that will set this value to zero.

In other words it should set te value to zero as soon as it’s wattage is greater than 12000 (the total value of my solarpanels)

Is there anyone who could give me a hand with this

Kind regards
Vincent

I have a similar behavior with my solar panel inverter who does not go to 0 before midnight.
I am working with the integration developer to get this done, a template is a workaround and not the solution.
However, you can set the value to anything via a script but this will only work if you donot receive values over and over again … or, you can set a template that will only accept readings from the inverter in a certain period.
The script I use can be found in HACS scripts

I use an optical energy meter reader that shows negative values when returning energy to the net. I removed the negative values with this sensor code:

      - name: grid_power_spent
        state: >-
          {% set power = states('sensor.stromzahler_sm_16_7_0') | float %}
          {% if power > 0.0 %} {{ (states('sensor.stromzahler_sm_16_7_0')|float) }}
          {% else %} 0.0 {% endif %}
        device_class: power
        unit_of_measurement: W    

You can use a similar logic to set your values to zero when they are above 12000.