You need to stop confusing power and energy they are very different things. The energy dashboard only uses energy sensors. Not power sensors. So, “the energy dashboard has a section for energy from the grid and another section for energy returned to grid”.
You would require a couple of template sensors to split your power sensor into two parts (to grid and from grid). Then feed those two to the Riemann Sum integration to get two energy sensors you can use in the dashboard.
Something like this (i guessed your sensor name, you will probably have to change it):
template:
- sensor:
- name: Power to Grid
unit_of_measurement: W
state_class: measurement
device_class: power
availability: "{{ states('sensor.grid_power_flow')|is_number }}"
state: >
{% if states('sensor.grid_power_flow')|float(0) <= 0 %}
{{ states('sensor.grid_power_flow')|float(0)|abs }}
{% else %}
0
{% endif %}
- name: Power from Grid
unit_of_measurement: W
state_class: measurement
device_class: power
availability: "{{ states('sensor.grid_power_flow')|is_number }}"
state: >
{% if states('sensor.grid_power_flow')|float(0) >= 0 %}
{{ states('sensor.grid_power_flow') }}
{% else %}
0
{% endif %}
Remember: These power sensors must go to the Riemann Sum integration to be converted to energy sensors. You can use those in the energy dashboard.