Get consumption from Victron Modbus

I use Home Assistant to grab the data from Modbus with these sensors:

#Modbus sensors for Victron sensors
  - platform: modbus
    registers:
      - name: "Victron Battery" #Battery SOC
        hub: victron
        data_type: uint
        unit_of_measurement: "%"
        slave: 100
        register: 843
        scale: 1
      - name: "Victron Current Power Usage"
        hub: victron
        data_type: uint
        unit_of_measurement: "W"
        slave: 100
        register: 817
        scale: 1
      - name: "Victron Grid Power"
        hub: victron
        data_type: int
        unit_of_measurement: "W"
        slave: 100
        register: 820
        scale: 1
      - name: "Victron Battery Power"
        hub: victron
        data_type: int
        unit_of_measurement: "W"
        slave: 100
        register: 842
        scale: 1
      - name: "Victron Battery State"
        hub: victron
        data_type: uint
        slave: 100
        register: 844
        scale: 1
      - name: "Victron PV power"
        hub: victron
        data_type: uint
        unit_of_measurement: "W"
        slave: 100
        register: 850
        scale: 1
      - name: "Victron ESS BatteryLife state"
        hub: victron
        data_type: uint
        slave: 100
        register: 2900
        scale: 1
      - name: "Victron ESS Minimum SOC"
        hub: victron
        data_type: uint
        slave: 100
        register: 2901
        scale: 0.1
        #VEBus devices = Multiplus = UnitID 242 = Device Instance 261 
      - name: "Victron Grid voltage"
        hub: victron
        data_type: uint
        slave: 242
        register: 3
        scale: 0.1
        unit_of_measurement: "V"      
      - name: "Victron Essential usage"
        hub: victron
        data_type: int
        slave: 242
        register: 23
        scale: 10
        unit_of_measurement: "W"      
      - name: "Victron VEBus Input Power 1"
        hub: victron
        data_type: int
        slave: 242
        register: 12
        scale: 10
        unit_of_measurement: "W"      
      - name: "Victron VEBus State"
        hub: victron
        data_type: uint
        slave: 242
        register: 31
        scale: 1
      - name: "Victron VEBus Error"
        hub: victron
        data_type: uint
        slave: 242
        register: 32
        scale: 1
      - name: "Victron energy meter"
        hub: victron
        data_type: int
        slave: 30
        register: 2600
        unit_of_measurement: "W" 
      - name: "Victron Grid Setpoint"
        hub: victron
        data_type: int
        slave: 100
        register: 2700
        unit_of_measurement: "W" 

I calculate some of the other ones using template sensors:

  - platform: template
    sensors:
    #Victron template sensors
          victron_non_essential_usage:
            friendly_name: 'None essential usage'
            value_template: >
                {{ (states("sensor.victron_energy_meter") | float - states("sensor.victron_vebus_input_power_1") | float ) | abs }}
            unit_of_measurement: 'W'
          victron_grid_usage:
            friendly_name: 'Grid usage'
            value_template: >
              {% if float(states("sensor.victron_grid_power")) > 0 %}
                {{ (states("sensor.victron_grid_power") | float | round (0) ) }}
              {% else %}
                0
              {% endif %}        
            unit_of_measurement: 'W'
      victron_batterylife_status:
        friendly_name: "BatteryLife Status"
        value_template: >-
          {% if is_state('sensor.victron_ess_batterylife_state', '0') %}
            Unused, BL disabled
          {% elif is_state('sensor.victron_ess_batterylife_state', '1') %}
            Restarting 
          {% elif is_state('sensor.victron_ess_batterylife_state', '2') %}
            Self-consumption
          {% elif is_state('sensor.victron_ess_batterylife_state', '3') %}
            Self-consumption
          {% elif is_state('sensor.victron_ess_batterylife_state', '4') %}
            Self-consumption
          {% elif is_state('sensor.victron_ess_batterylife_state', '5') %}
            Discharge disabled
          {% elif is_state('sensor.victron_ess_batterylife_state', '6') %}
            Force charge
          {% elif is_state('sensor.victron_ess_batterylife_state', '7') %}
            Sustain
          {% elif is_state('sensor.victron_ess_batterylife_state', '9') %}
            Keep batteries charged   
          {% elif is_state('sensor.victron_ess_batterylife_state', '10') %}
            BL Disabled
          {% elif is_state('sensor.victron_ess_batterylife_state', '11') %}
            BL Disabled (Low SoC) 
          {% else %}
            Unknown - {{ states("sensor.victron_ess_batterylife_state") }}
          {% endif %}
      victron_inverter_state:
        friendly_name: "Inverter State"
        value_template: >-
          {% if is_state('sensor.victron_vebus_state', '0') %}
            Off
          {% elif is_state('sensor.victron_vebus_state', '1') %}
            Low Power
          {% elif is_state('sensor.victron_vebus_state', '2') %}
            Fault
          {% elif is_state('sensor.victron_vebus_state', '3') %}
            Bulk
          {% elif is_state('sensor.victron_vebus_state', '4') %}
            Absorption
          {% elif is_state('sensor.victron_vebus_state', '5') %}
            Float
          {% elif is_state('sensor.victron_vebus_state', '6') %}
            Storage
          {% elif is_state('sensor.victron_vebus_state', '7') %}
            Equalize
          {% elif is_state('sensor.victron_vebus_state', '8') %}
            Passthru
          {% elif is_state('sensor.victron_vebus_state', '9') %}
            Inverting
          {% elif is_state('sensor.victron_vebus_state', '10') %}
            Power assist
          {% elif is_state('sensor.victron_vebus_state', '11') %}
            Power supply
          {% elif is_state('sensor.victron_vebus_state', '252') %}
            Bulk protection
          {% else %}
            Unknown - {{ states('sensor.victron_vebus_state') }}
          {% endif %}
      victron_inverter_error:
        friendly_name: "Inverter Error"
        value_template: >-
          {% if is_state('sensor.victron_vebus_error', '0') %}
            No error
          {% elif is_state('sensor.victron_vebus_error', '1') %}
            Device is switched off because one of the other phases in the system has switched off
          {% elif is_state('sensor.victron_vebus_error', '2') %}
            New and old types MK2 are mixed in the system
          {% elif is_state('sensor.victron_vebus_error', '3') %}
            Not all- or more than- the expected devices were found in the system
          {% elif is_state('sensor.victron_vebus_error', '4') %}
            No other device whatsoever detected
          {% elif is_state('sensor.victron_vebus_error', '5') %}
            Overvoltage on AC-ou
          {% elif is_state('sensor.victron_vebus_error', '6') %}
            Error in DDC Program
          {% elif is_state('sensor.victron_vebus_error', '7') %}
            VE.Bus BMS connected- which requires an Assistant- but no assistant found
          {% elif is_state('sensor.victron_vebus_error', '10') %}
            System time synchronisation problem occurred
          {% elif is_state('sensor.victron_vebus_error', '14') %}
            Device cannot transmit data
          {% elif is_state('sensor.victron_vebus_error', '16') %}
            Dongle missing
          {% elif is_state('sensor.victron_vebus_error', '17') %}
            One of the devices assumed master status because the original master failed
          {% elif is_state('sensor.victron_vebus_error', '18') %}
            AC Overvoltage on the output of a slave has occurred while aready switched off
          {% elif is_state('sensor.victron_vebus_error', '22') %}
            This device cannot function as a slave
          {% elif is_state('sensor.victron_vebus_error', '24') %}
            Switch-over system protection initiated
          {% elif is_state('sensor.victron_vebus_error', '25') %}
            Firmware incompatibility
          {% elif is_state('sensor.victron_vebus_error', '25') %}
            Internal error
          {% else %}
            Unknown - {{ states('sensor.victron_vebus_error') }}
          {% endif %}

And then finally I convert the instantaneous values (W) to kWh using the integration sensor:

#Victron energy sensors (from instant W to energy)
  - platform: integration
    source: sensor.victron_pv_power
    name: 'Victron PV energy'
    unit_prefix: k
    round: 2

  - platform: integration
    source: sensor.victron_grid_power
    name: 'Victron Grid energy'
    unit_prefix: k
    round: 2

  - platform: integration
    source: sensor.victron_current_power_usage
    name: 'Victron total home energy'
    unit_prefix: k
    round: 2

One thing to note is that the modbus sensors update only once every 30s. So the values won’t be as accurate as in VRM, but it works well enough.

End result:

image

Edit: Sorry, forgot to add: the monthly totals are done using the utility_meter component of Home Assistant:

utility_meter:
  victron_pv_energy_daily:
    source: sensor.victron_pv_energy
    cycle: daily
  victron_pv_energy_monthly:
    source: sensor.victron_pv_energy
    cycle: monthly
  victron_home_energy_monthly:
    source: sensor.victron_total_home_energy
    cycle: monthly
  victron_home_energy_daily:
    source: sensor.victron_total_home_energy
    cycle: daily
  victron_grid_energy_monthly:
    source: sensor.victron_grid_energy
    cycle: monthly
  victron_grid_energy_daily:
    source: sensor.victron_grid_energy
    cycle: daily
4 Likes