Template - State_Class: total_increasing

Hello

I tried to create a new sensor for energy :slight_smile:

 - platform: template
   sensors:
        shelly_energy:
          friendly_name: "Shelly total Energy KWH"
          unit_of_measurement: 'kWh'
         #  state_class: total_increasing
          value_template: "{{ states('sensor.shellyem3_bcff4dfd1d62_channel_a_energy') |float  + states('sensor.shellyem3_bcff4dfd1d62_channel_b_energy') }}" 
          device_class: "energy"

but I am not able to choose the state_class: total increasing in order to include it in the energy board

Do you have any idea how to create such sensor ?

Thank you

That’s because your Template Sensor is configured in legacy format which doesn’t support the state_class option.

You can add state_class: total_increasing to it via Manual Customization or re-configure it in modern format.

Hi thank I move all to my template.yaml and all is working !

Glad to hear that switching to modern format resolved the problem.

Please consider marking my post with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other words that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.