Victron system integration

Hi,

Sorry i have posted this on Victron forum and if something comes up there i’ll sync here.

I have following :

  • Multiplus II
  • Cerbo GX
  • Fronius AC Coupled inverter (connected to Cerbo with modbus)
  • Carlo Gavazzi EM24 meter (connected to Cerbo with modbus)
  • Victron MPPT

My system is 3 phase, the Fronius is producing on L3 and Multiplus II on L1
I want to have the battery, grid and solat into Home Assistant Energy dashboard and i got most of it in but it seems wrong, HASS shows more usage compared to VRM dashboard so i think it’s wrong.

For now i am using :

Grid L1 - Energy from net 2603
Grid L2 - Energy from net 2604
Grid L3 - Energy from net 2605
Grid L1 - Energy to net 2606
Grid L2 - Energy to net 2607
Grid L3 - Energy to net 2608

to get the consumpton from grid and return to grid.

To get the Victron MPPT in i use :
PV - DC-coupled power 850
to get the Fronius production in i use :
PV - AC-coupled on input L3 813

For battery i use :
Battery Power (System) 842
and then i make two sensors to have both + and - energy going to/from battery

My problem is that when i compare VRM portal to HASS i see following :

  • Grid consumption in VRM is lower than HASS shows
  • Solar production is higher in VRM than on HASS
  • Total consumption from GRID is higher on HASS compared to VRM
  • Energy to battery is higher in VRM than on HASS

Any ideas whats causing this ?

30261-1646650701545
30228-1646650727504

30271-1646650715335

30272-1646650750045

I should mention that my electricity provider has a meter where it calculates on all phases therefore i always go for hitting 0 meaning don’t feed back if i can use it. The consumtion in the house is on 3 phases and Victron system using ESS makes sure that when i use 1000w on one phase the system produces 1000w on the phase the inverter is on so the sum is 0w and i don’t pay to use 1000w when i also return 1000w but on another phase. I don’t know if any of this makes problem for the energy dashboard.

Energy dashboard config:

Modbus config :

 -  name: victron
    retry_on_empty: true
    retries: 10
    type: tcp
    host: 10.10.0.85
    port: 502
    sensors:
    - name: "Energy from Grid L1"    
      unit_of_measurement: "kWh"
      slave: 40
      address: 2603
      data_type: uint16
      scale: 0.01
      precision: 1
      scan_interval: 20
      device_class: energy
      state_class: total_increasing
    - name: "Energy from Grid L2"    
      unit_of_measurement: "kWh"
      slave: 40
      address: 2604
      data_type: uint16
      scale: 0.01
      precision: 1
      scan_interval: 20
      device_class: energy
      state_class: total_increasing
    - name: "Energy from Grid L3"    
      unit_of_measurement: "kWh"
      slave: 40
      address: 2605
      data_type: uint16
      scale: 0.01
      precision: 1
      scan_interval: 20
      device_class: energy
      state_class: total_increasing
    - name: 'Energy to Grid L1'
      unit_of_measurement: "kWh"
      slave: 40
      address: 2606
      data_type: uint16
      scale: 0.01
      precision: 1
      scan_interval: 20
      device_class: energy
      state_class: total_increasing
    - name: 'Energy to Grid L2'
      unit_of_measurement: "kWh"
      slave: 40
      address: 2607
      data_type: uint16
      scale: 0.01
      precision: 1
      scan_interval: 20
      device_class: energy
      state_class: total_increasing
    - name: 'Energy to Grid L3'
      unit_of_measurement: "kWh"
      slave: 40
      address: 2608
      data_type: uint16
      scale: 0.01
      precision: 1
      scan_interval: 20
      device_class: energy
      state_class: total_increasing
    - name: "PV - DC power"      
      data_type: uint16
      unit_of_measurement: "W"
      slave: 100
      address: 850
      precision: 2
      scan_interval: 20
      device_class: power
    - name: "PV - AC power Fronius"      
      data_type: uint16
      unit_of_measurement: "W"
      slave: 100
      address: 813
      precision: 2
      scan_interval: 20
      device_class: power
    - name: 'Battery Power System'
      unit_of_measurement: "W"
      slave: 100
      address: 842
      data_type: int16
      scale: 1.0
      precision: 0
      scan_interval: 20
      device_class: power

Sensors :

- platform: integration
  source: sensor.pv_dc_power
  name: "Solar Energy Yield DC"
  unit_prefix: k
  round: 2  
- platform: integration
  source: sensor.pv_ac_power_fronius
  name: "Solar Energy Yield AC"
  unit_prefix: k
  round: 2  
- platform: integration
  source: sensor.battery_charge_power
  name: Battery Charge
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.battery_discharge_power
  name: Battery Discharge
  unit_prefix: k
  round: 2

Template :

- platform: template
  sensors:    
    battery_discharge_power:
      device_class: power
      friendly_name: "Battery Discharge"
      unit_of_measurement: "W"
      value_template: "{{ max(0, 0 - states('sensor.battery_power_system') | float) }}"
    battery_charge_power:
      device_class: power
      friendly_name: "Battery Charge"
      unit_of_measurement: "W"
      value_template: "{{ max(0, states('sensor.battery_power_system') | float) }}"
2 Likes

Any of you guys have an idea ?

@lsgv @Crumpy10 @farmio @foonji

Hi, so you’re getting “energy” (kWh) from “power” (kW) ?
That sort of approximation (Riemann sum integral) would explain some differences.
I’m trying to do a similar setup.
Single phase with solar, SmartSolar charger (DC-side) and Fimer inverters (on AC-Out)
On the AC side it’s easy to measure, even some Shelly EMs with CT clamps will do it.
But for the batteries it’s not that easy, it seems.

Is there any final solution ?
How you integrated a Victron into HA energy dasboard ?
Thanks

Looking forward to workable solution. I got similar setup and after many hours I end up with no data at all.
This is how it looks like.


Data not comming out. After several days still same message:

After a week playing arround with Victron and Modbus I have satisfactory solution. From my poing of view problem is scan_interval: 20 seconds in your modbus config is way too much. Try 5 seconds. I read somewhere that scan_interval: under 5 seconds can cause problems and never tried lower interval.
My data are not equal to VRM but very close. VRM data mesures continuosly, but modbus in intervals and I think that is the problem.
Screenshot 2022-11-05 at 14.35.39 Screenshot 2022-11-05 at 14.36.41 Screenshot 2022-11-05 at 14.53.14 Screenshot 2022-11-05 at 14.53.24

1 Like

Hi, just bumped into this.
Yes I would agree that 20 seconds is too wide of a gap.
I have a Venus GX, which is fairly slow, but with several readings every 5 seconds, the only problems I had with it hanging/freezing is when my internet connection becomes unstable.

Can you please elaborate on your implementation?
Are you getting a “battery power” reading every 5 seconds and applying a Riemann Sum to estimate battery energy?
Is this a single entity reading, for both “from” and “to” battery? (and HA correctly sums the positive as “to” and negative as “from” battery?)

Thanks

1 Like

Hi,
here is little bit more info about my implementation.
I have got Cerbo GX for monitoring which has no problem with 5 sec interval.
In modbus I am reading address 842 from system.

    - name: "Victron Battery Power"
      data_type: int16
      unit_of_measurement: "W"
      slave: 100
      address: 842
      scale: 1
      device_class: power
      scan_interval: 5

from that I created 2 sensors and calculate charge and discharge:

    # Sensors for energy dashboard Battery From senzor witch positive and negative state in to two sensors
    battery_discharge_power:
      device_class: power
      friendly_name: "Victron Battery Discharge (sensor)"
      value_template: "{{ max(0, 0 - states('sensor.victron_battery_power') | float) }}"

    battery_charge_power:
      device_class: power
      friendly_name: "Victron Battery Charge (sensor)"
      value_template: "{{ max(0, states('sensor.victron_battery_power') | float) }}"

- platform: integration
  source: sensor.battery_charge_power
  name: Victron_Energy_into_battery (sensor)
  method: left

- platform: integration
  source: sensor.battery_discharge_power
  name: Victron_Energy_from_battery (sensor)
  method: left

And that’s all. Code is not mine I just found it probably on github, played with it and it starts working :slight_smile: I am still home assistant begginer.

Here is github project from which I took most of the code.
I hope this helps.

1 Like

Very cool, thank you for sharing!
I lacked the confidence to experiment with this without a practical example to start with.
I’m very much of a beginner myself.

I don’t know how to reference platform: integration sensors in the templates.yaml file (that’s where I keep all my customized sensors), so I ended up leaving these two in the main configuration.yaml

sensor:
  - platform: integration
    name: "Victron Battery Energy Input"
    unique_id: 'victron_battery_energy_input'
    source: sensor.victron_battery_charge_power
    method: left
    unit_prefix: k
    unit_time: h
    
  - platform: integration
    name: "Victron Battery Energy Output"
    unique_id: 'victron_battery_energy_output'
    source: sensor.victron_battery_discharge_power
    method: left
    unit_prefix: k
    unit_time: h

Now I have a pretty much complete integration if you can call it that :slightly_smiling_face:

Next I’ll be turning to Node-RED (inside Venus Large OS, on the Victron side of things), to automatically manage battery/grid according to the solar forecast and my house average consumption.
I want to do it on the Victron side, so it remains somewhat independent of HA.

2 Likes

https://community.victronenergy.com/questions/6958/kva-hours-or-kwh.html

It also states here that energy metering of the MultiPlus is not accurate.

Just a small heads-up for anyone interested.
I’m working on a modbus GX victron custom integration to simplify the HA → victron integration.

This integration automatically discovers devices that are part of your victron setup and will make all registers available as entities.
Read only/write support works without any issues.
It is an acceptance release so everything should work but you might run into small bugs.

3 Likes

Hi, I have installed it over hacs, how can I use it now ? There is no explanation.

You should be able to install the integration like any other ui integration after you have installed the integration via hacs (and have restarted HA).
“settings” → “devices and services” → “add integration”.
This is basically the same for every core / hacs integration.

1 Like

(Assuming that you have the latest HA release installed)
Are you using the core modbus (yaml) integration in your instance?
Please note that the victron integration cannot be run / installed while the core modbus integration is loaded.
If you aren’t using any other integration that uses pymodbus then please try the action again.
After which (please) provide the error that will be visible under:
“settings” → “system” → “logs”

1 Like

@sfstar i am using modbus integration for my heat pump …

In that case your gonna have to wait until the internal modbus integration is upgraded to v3.0.0 or higher.
Which is currently (based on a statement by it’s maintainer) planned after pymodbus 3.1.x is released.
Which is planned for this month.
So expect interoperability in january / february (when the internal modbus integration is planned to be bumped)

1 Like

How to get charge and discharge of the battery from the integration?

Is it possible to configure this using the Energy page on Home assistant? I was able to use the integration and have access to a lot of entities ill use to do some automations … But now i would like to use the production/consume/bateries … to have that info on the Energy page like i have on VRM app or the GX console.

Good Afternoon All

Same here, the integration is awesome and pulling out a lot of information. But notice that you can’t use this as is with the energy dashboards. seems one will need to use the sensor and create new template sensors as they do not show up in the energy dashboards. has anyone had a look at this and made it work correctly.

I am busy removing my old manual yaml code for this and will then start looking into the template.