I am using the following integration template to generate a power chart from an energy sensor:
sensor:
- name: Battery Energy (Sungather)
platform: integration
source: sensor.inverter_battery_power
unit_time: h
sensor.inverter_battery_power is an MQTT entity, which appears to be functioning correctly. However, the integration values are hugely negative and trending downwards over time. Here is a statistics graph of both:
My understanding of calculus is very rusty, but my intuition is that this is not working correctly.
However you may be seeing a lot of accumulated errors because you are using an inappropriate integration method. Try left, instead of the default trapezoidal.
In this case, negative values indicate power going into the battery (ie, it is being charged). I have separate template sensors that splits it into two different sensors for the Energy dashboard.