I have setup a sensor that monitors my wallcharger for my EV. What I do is a multistage setup that I will explain first:
The first sensor is a binary one that will switch on as soon as the sensor.p1_meter_active_power is above 9800W and will switch of when below.
entity_id: sensor.p1_meter_active_power
hysteresis: 0
lower: null
position: above
sensor_value: 11241
type: upper
upper: 9800
device_class: battery_charging
icon: mdi:ev-station
friendly_name: Ratio Solar Active
Next I have a sensor that copies the sensor.p1_meter_active_power as long as the switch is active ( I use a factor 0.95 to compensate for other energy consumption):
- sensor:
- name: Ratio Solar
unique_id: sensor.ratio_solar_power
icon: "mdi:ev-station"
unit_of_measurement: "W"
device_class: power
state_class: total
state: >
{% if states.binary_sensor.ratio_solar_active.state == 'on' %}
{{ (0.95 * states("sensor.p1_meter_active_power")|float) }}
{% else %}
0
{% endif %}
Finally I have created an integral sensor that uses the previous to get the energy. It uses the Trapezoidal rule, with a 2 digit precision and measures in Wh. Its history graph shows this:
The graph for both the P1 and the wallcharger (Ratio Solar) show this:
However the energy dashboard shows a positive value of 680.22kWh for the Ratio Solar Energy sensor and a -672.86kWh of untracked energy:
The value of 7.36kWh is the correct power consumption of the wall charger. What am I doing wrong here? These extreme values only occur at the start of the charge.