Total energy

Dear team,
i want to make total energy consumption :

Total energy = Energy A + Energy B

how to configurate in home assistant.

Thank you for any help!

Richard

e.g.

template:
  - sensor:
      - name: Total Energy
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: kWh
        state: "{{ states('sensor.energy_a')|float(0) + states('sensor.energy_b')|float(0) }}"
        availability: "{{ has_value('sensor.energy_a') and has_value('sensor.energy_b') }}"