Your template sensor does not have a state class. Therefore the Riemann Sum sensor will not have a state class. Therefore it can not be used by the energy dashboard.
Legacy template sensors do not have support for state class and will not be getting new features.
You should use the new template sensor format for new sensors.
(configuration.yaml)
template:
- sensor:
- name: current electrical consumption dhw
unique_id: current_electrical_consumption_dhw
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set ElectricPower = states('sensor.l1_power_heatpump') | float %}
{% set epower = states('sensor.l2_power_heatpump') | float %}
{% if is_state('binary_sensor.daalderop_daalderop_three_way_valve','off') and ElectricPower > 300 %}
{{ (ElectricPower + epower) | round(2) }}
{% else %}
{{ 0 }}
{% endif %}
availability: >
{{ has_value('sensor.l1_power_heatpump') and
has_value('sensor.l2_power_heatpump') }}
You will need to restart home assistant if this is the first time you have used the new template integration. After that you can use the reload option instead.