Problem sensor templates Update

Hi,
I got error messages since the last update (2025.12) about the sensor templates. Unfortunately I never played with templates in a active way, so I need some basic help to migrate the code. I tried my very best with the first sensor as you can see in the Code below. But this cannot be right. Could you please give me concrete order what to change in the yaml that I will get no errors?

Thank you very much!

Markus

sensor:
  - platform: template
    sensors:
      # Template sensor for current power comsumption
      power_current:
        unit_of_measurement: W
        default_entity_id: sensor.power_current
        availability: '{{ [ states(''sensor.shellypro3em_34987a469ca0_phase_a_active_power''),
            states(''sensor.shellypro3em_34987a469ca0_phase_b_active_power''), states(''sensor.shellypro3em_34987a469ca0_phase_c_active_power'')
            ] | map(''is_number'') | min }}'
        name: Power Current
        state: '{{ states(''sensor.shellypro3em_34987a469ca0_phase_a_active_power'')|float
            + states(''sensor.shellypro3em_34987a469ca0_phase_b_active_power'')|float +
            states(''sensor.shellypro3em_34987a469ca0_phase_c_active_power'')|float }}'
      

      # Template sensor for values of power import (active_power > 0)
      power_import:
        friendly_name: "Power Import"
        unit_of_measurement: "W"
        value_template: >-
          {% if (states('sensor.shellypro3em_34987a469ca0_phase_a_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_b_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_c_active_power')|float) > 0 %}
            {{ states('sensor.shellypro3em_34987a469ca0_phase_a_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_b_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_c_active_power')|float }}
          {% else %}
            {{ 0 }}
          {% endif %}
        availability_template: "{{
          [ states('sensor.shellypro3em_34987a469ca0_phase_a_active_power'),
          states('sensor.shellypro3em_34987a469ca0_phase_b_active_power'),
          states('sensor.shellypro3em_34987a469ca0_phase_c_active_power')
          ] | map('is_number') | min
          }}"

      # Template sensor for values of power export (active_power < 0)
      power_export:
        friendly_name: "Power Export"
        unit_of_measurement: "W"
        value_template: >-
          {% if (states('sensor.shellypro3em_34987a469ca0_phase_a_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_b_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_c_active_power')|float) < 0 %}
            {{ (states('sensor.shellypro3em_34987a469ca0_phase_a_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_b_active_power')|float + states('sensor.shellypro3em_34987a469ca0_phase_c_active_power')|float) * -1 }}
          {% else %}
            {{ 0 }}
          {% endif %}
        availability_template: "{{
          [ states('sensor.shellypro3em_34987a469ca0_phase_a_active_power'),
          states('sensor.shellypro3em_34987a469ca0_phase_b_active_power'),
          states('sensor.shellypro3em_34987a469ca0_phase_c_active_power')
          ] | map('is_number') | min
          }}"

      # Template sensor for values of power consumption
      power_consumption:
        friendly_name: "Power Consumption"
        unit_of_measurement: "W"
        value_template: >-
          {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
            {{ 0 }}    
          {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
            {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
          {% else %}
            {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
          {% endif %}

      # Template sensor for values of energy Solar generation (solar_power > 0)
      power_solargen:
        friendly_name: "Power Solar Generation"
        unit_of_measurement: "W"
        value_template: >-
          {% if ( 0 ) > 0 %}
            {{ ( 0 ) }}
          {% else %}
            {{ 0 }}
          {% endif %}

  # Sensor for Riemann sum of energy import (W -> Wh)
  - platform: integration
    source: sensor.power_import
    name: energy_import_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy export (W -> Wh)
  - platform: integration
    source: sensor.power_export
    name: energy_export_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy consumption (W -> Wh)
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption_sum
    unit_prefix: k
    round: 2
    method: left

Go here and read thru this thread to help you adjust those.

Also here is a custom Integration to convert them for you if that doesn’t work for you.

Comment there if you need more help.

There is a process here in this thread on templates deprecation:

You should use @petro script to help migrate