Setup E3DC PV Inverter in new Energy Management (HA 2021.8)

My house runs on a E3DC S10 Mini. It provides values for power consumption, grind consumption, solar production and battery consumption.
It is integrated in Home Assistant via Modbus

Modbus Configuration
# E3DC S10 Mini photovoltaic inverter
- name: E3DC
  type: tcp
  host: !secret E3DC_IP_ADDRESS
  port: 502
  retry_on_empty: true
  retries: 10
  scan_interval: 10 #Default Scan Interval is every 30 seconds
  sensors:
    - name: E3DC solar power
      unit_of_measurement: W
      address: 40067
      device_class: power
    - name: E3DC battery power
      unit_of_measurement: W
      address: 40069
      device_class: power
    - name: E3DC battery soc
      unit_of_measurement: '%'
      address: 40082
      data_type: uint
      device_class: battery
    - name: E3DC power consumption
      unit_of_measurement: W
      address: 40071
      device_class: power
    - name: E3DC grid power
      unit_of_measurement: W
      address: 40073
      device_class: power

These sensors provide a power read out in Watt [W], whereas both, sensor.e3dc_battery_power and sensor.e3dc_grid_power can be positive, or negative, depending on the flow of the power (i.e. charging or discharging the battery / consuming power from the grid or returing power produced by my photovoltaic system into the grid).

The energy management introduced to Home Assistant with version 2021.8 requires energy sensors rather than power sensors. As this is not provided by the inverter, I would need to use the Riemann-Integration.

However, if I understand correctly the energy management setup dashboard is asking for the grid consumption only (i.e. integration of the postive values of sensor.e3dc_grid_power), and the return to grid (i.e. the integration of the negative values of sensor.e3dc_grid_power). There I have the question: How do I achieve this?

Additionally I do not see the possibility to track the energy consumption of the house, nor how what the batteries role in the whole energy management is, or do I misinterpret something?

With template sensors:

sensor
  - platform: template
    sensors:
      # Negative values only
      e3dc_net_power_neg2pos_only:
        unit_of_measurement: 'W'
        value_template: >
          {% if states('sensor.e3dc_net_power') | int > 0 %}
            0
          {% else -%}
            {{ (states('sensor.e3dc_net_power') | int) | abs }} 
          {% endif %}      

      # Positve values only
      e3dc_net_power_pos_only:
        unit_of_measurement: 'W'
        value_template: >
          {% if states('sensor.e3dc_net_power') | int > 0 %}
            {{ states('sensor.e3dc_net_power') }}
          {% else -%}
            0
          {% endif %}

and then use these sensors in the Riemann integration.

No clue about this.
As long as i know, battery is not implemented.

Thanks for your help. This works great.