Ok, actually I found out that the default Energy integration does a pretty good job.
I created some helpers:
- battery_charge_power = inverter0_battery_voltage * inverter0_battery_charging_current
- battery_charge_power_total - Riemann sum of the above
- similar for battery_discharge_power
- pv_output_kwh - Riemann sum of the inverter0_pv_charging_power
- pv_output_kwh_total - utility meter of the above (does not work)
I manually edited the states of the above to convert them to device_class: energy and state_class: total. They probably won’t survive a HA restart so I probably need to follow this post How to edit a "Riemann sum integral" helper - #6 by worker72
At least I got some things to show up, will need to wait and see if it works as intended.