Weird behaviour on power monitoring

Hi all,

I have setup integration between my Victron inverter and HA via modbus and I can see the readings fine. However I seem to get some strange behaviour when trying to convert the readings in W from Victron to kWh to monitor on the energy dashboard. I see random jumps in the integration calculated values on the history/energy pages.

Modbus:

modbus:
  - name: Victron
    type: tcp
    host: 192.168.2.10
    port: 502
    sensors:
      - name: "Victron Battery Power"
        unit_of_measurement: W
        slave: 100
        address: 842

Template sensors (to flip negative readings to a positive for discharge)

  - sensor:
      - name: "ESS_battery_discharge_power"
        unique_id: sensortemplate.batterydischarge
        device_class: power
        unit_of_measurement: "W"
        state: "{{ max(0, 0 - states('sensor.victron_battery_power') | float) }}"

      - name: "ESS_battery_charge_power"
        unique_id: sensortemplate.batterycharge
        device_class: power
        unit_of_measurement: "W"
        state: "{{ max(0, states('sensor.victron_battery_power') | float) }}"

Integration sensors (used in energy dashboard)

sensor:
    - platform: integration
      source: sensor.ESS_battery_discharge_power
      name: ESS Battery Discharge
      unit_prefix: k
      round: 2

    - platform: integration
      source: sensor.ESS_battery_charge_power
      name: ESS Battery Charge
      unit_prefix: k
      round: 2

Now when I display these on history tab, I can see that periodically ‘ESS Battery Charge’ will jump a few kWh whereas its been getting a constant feed from ‘Victron Battery Power’. See the example below, it reported a charge at 1:20:32 of 1343W which stopped at 1:20:47, but for some reason the ESS Battery Charge has reported an increase of 4.32kWh (190.48 reported at 18:33 the previous evening, then 194.8 reported at 1:20:32). This coincides with solar charging stopping (a bit after 18:33)

In the image below you can see the last reported positive readings (charging) around 18:35pm, so ESS battery charge is rightly showing 0 until it gets some charge at 1:20:32, but I cant understand why it jumps 4kWh at that point.

Any ideas? It’s not been showing any update in charge overnight, quite rightly, and it seems the next spike after 1:20am seems to be added correctly (note the little increase far right to ESS Battery charge). It shouldnt be accumulating little changes in that time as Victron Battery Power has been reporting below 0.

This shows as a very obvious blip on the Energy Dashboard between 1-2am which never happened in reality.

From Victron reporting, it is showing the ~3kWh consumption from our hot water heater running at the time, but the line showing battery state does not move as its not being used at the time (running on cheap grid power).

Seen this again recently, so quick bump before I raise it as a bug. From what I can see there are no power values being reported that should make it jump as much as it does on the energy calculation. It makes it look like significant energy is being put into the battery when it hasn’t been.

I’m having the same issues with my Victron system.
Did you raise a bug for this?

Sorry dont seem to have gotten a notification for this. The fix was to change the measurement ‘method’ to ‘left’. I can’t remember the ins and outs but found it in the docs at some point and that sorted it out. I seem to remember the default was trying to interpolate the value, assuming that it ramped up over time from one value to the other, whereas in reality it jumped.

sensor:
    - platform: integration
      source: sensor.ESS_battery_discharge_power
      unique_id: sensorintegration.batterydischarge
      name: ESS Battery Discharge
      unit_prefix: k
      round: 3
      method: left

    - platform: integration
      source: sensor.ESS_battery_charge_power
      unique_id: sensorintegration.batterycharge
      name: ESS Battery Charge
      unit_prefix: k
      round: 3
      method: left
1 Like