Help with Battery Sensor for Energy Dashboard

Please help…

I have a solerman integration and it has 1 sensor for charge and discharge

sensor.solarman_battery_charge_discharge_power
state_class: measurement
unit_of_measurement: kW
device_class: power
icon: mdi:home-battery
friendly_name: Solarman Battery Charge / Discharge Power

Im trying to create two sensor for the battery usage in the Energy Dashboard.

sensor:
  - platform: template
    sensors:
      charge_energy:
        friendly_name: "Charge Energy"
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: kWh
        value_template: >
          {% set sensor_state = states('sensor.solarman_battery_charge_discharge_power') | float %}
          {{ sensor_state if sensor_state >= 0 else 0 }}
        
      discharge_energy:
        friendly_name: "Discharge Energy"
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: kWh
        value_template: >
          {% set sensor_state = states('sensor.solarman_battery_charge_discharge_power') | float %}
          {{ 0 - sensor_state if sensor_state < 0 else 0 }}

at facevalue they look correct but the KHW in the energy dashboard are way too high for what was actually charged and discharged in KW.

Where am i going wrong please help.
Many thanks