I have a Aeotec Home Energy Meter ZW095 Which measures my energy consumption. I also have a grid tied solar panel inyecting current to the house. The meter has 4 modes of operation:

Value Description
0 Energy absolute value
1 Algebraic sum energy
2 Consuming electricity
3 Generating electricity

I set it to (1) Algebraic sum energy. Which is the only one that shows positive and negative power(W) values (negative when it is injecting energy to the grid). The energy as stated is being calculated using an algebraic sum. This means that the total energy can increase or decrease depending of your energy production and consumption.

Home Assistant on the other hand expect two different entities (both of them positive). One for Total consumption, and one for total production.

My question is: Is there an easy way of calculating the production and consumption entities based on wether the algebraic energy is increasing or decreasing. In Other words if the meter energy goes from 102.31 kWh to 102.33 then Consumption should increase by 0.02. But if energy goes from 102.31 to 102.30 then Production should increase by 0.01.

Have you found a solution?
Have the same Energy Meter and same Problem.
Actually I have set it to Value “0” because I had no Solar panel.
But now I have solar.
Tried Setting “1” but all readings of the 3 phases are negative now and not showing “real values”

I ended up recalculating energy production based on power usage
First I made 2 templates, separating FROM grid and TO grid power,

Then calculated 2 separate energy entities (FROM and TO grid) and those entities can be plugged to the energy dashboard.

from template.yaml

- name: "HEM5 To Grid"
unique_id: hem5_to_grid
unit_of_measurement: "W"
device_class: power
state: >
{% set grid_out = states('sensor.hem5_power') | float(0) %}
{{ - grid_out if grid_out < 0 else 0 }}
- name: "HEM5 From Grid"
unique_id: hem5_from_grid
unit_of_measurement: "W"
device_class: power
state: >
{% set grid_out = states('sensor.hem5_power') | float(0) %}
{{ grid_out if grid_out > 0 else 0 }}

Then calculate energy based on these templates:

from sensor.yaml:

- platform: integration
source: sensor.hem5_from_grid
name: HEM5 Energy From Grid
unique_id: HEM5_energy_from_grid
method: left
unit_prefix: k
round: 2
- platform: integration
source: sensor.hem5_to_grid
name: HEM5 Energy To Grid
unique_id: HEM5_energy_to_grid
method: left
unit_prefix: k
round: 2

Hello,
I am trying to do the same. But only get positive values of power. If there is export then it’s zero. Of course I set up proper parameters for hem. Just like yours. Current reported is negative. But cannot simply calculate current * voltage as power factor is far from 1…
How did you make hem to report both positive and negative values of power?