Victron + HA + Energy dashboard

I’m trying to get working energy dashboard with my victron Energy system.
Into configuration.yaml I added this :

modbus: !include victron.yaml

        
template:
  - sensor:
      - name: "Battery power victron input"
        unit_of_measurement: "W"
        state: >
          {% if states('sensor.battery.power.victron')|float >= 0 %}
            {{ states('sensor.battery.power.victron') }}
          {% else %}
            0
          {% endif %}
      - name: "Battery power victron output"
        unit_of_measurement: "W"
        state: >
          {% if states('sensor.battery.power.victron')|float < 0 %}
            {{ -1 * states('sensor.battery.power.victron')|float }}
          {% else %}
            0
          {% endif %}
        
utility_meter:
  #total battery input power
  daily_battery_input_power:
    source: sensor.total_battery_input_power
    cycle: daily
  monthly_battery_input_power:
    source: sensor.total_battery_input_power
    cycle: monthly

  #total battery output power
  daily_battery_output_power:
    source: sensor.total_battery_output_power
    cycle: daily
  monthly_battery_output_power:
    source: sensor.total_battery_output_power
    cycle: monthly

and victrom.yaml is :

# modbus:
  - name: cerbo
    host: 192.168.0.200
    type: tcp
    port: 502
    sensors:
      # SYSTEM
      - name: "Battery Power Victron"
        data_type: int16
        unit_of_measurement: "W"
        slave: 100
        address: 842
        scale: 1
        device_class: power
        # MPPT 
      - name: "Production today"
        data_type: uint16
        unit_of_measurement: "kW"
        slave: 100
        address: 784
        scale: 0.1
        precision: 3
        device_class: energy
        state_class: total_increasing
        # GRID        
      - name: "From the grid"
        data_type: uint32
        unit_of_measurement: "kWh"
        slave: 31
        address: 2634
        scale: 0.01
        device_class: energy
        state_class: total_increasing
      - name: "To the grid"
        data_type: uint32
        unit_of_measurement: "kWh"
        slave: 31
        address: 2636
        scale: 0.01
        device_class: energy
        state_class: total_increasing

Ptoblem is that in the energy dashboard I can’t see a battery and also not a MPPT production
What I’m doing wrong ?
Thanks for help

Hi @Alda,

I was looking for something else and noticed your post, not sure if you managed to come right in the interim but I got it working using the following which have been quite reliable:

Victron Modbus Entry:

modbus:
  - name: victron
    host: 192.168.5.54
    type: tcp
    port: 502
    delay: 3
    sensors:
      - name: "Victron Battery Power System"
        unit_of_measurement: "W"
        slave: 100
        address: 842
        data_type: int16
        scale: 1.0
        precision: 0
        device_class: power

Template sensor to convert the single negative/positive values into two separate sensors:

  - platform: template
    sensors:
      victron_battery_power_input:
        device_class: power
        friendly_name: "Battery Input Power"
        unit_of_measurement: "W"
        value_template:
          "{% if states('sensor.victron_battery_power_system')|float >= 0 %}
          {{ states('sensor.victron_battery_power_system') }}
          {% else %}
          0
          {% endif %}"
        availability_template: >
          {{ states('sensor.victron_battery_power_system')|is_number}}

      victron_battery_power_output:
        device_class: power
        friendly_name: "Battery Output Power"
        unit_of_measurement: "W"
        value_template:
          "{% if states('sensor.victron_battery_power_system')|float < 0 %}
          {{ -1 * states('sensor.victron_battery_power_system')|float }}
          {% else %}
          0
          {% endif %}"
        availability_template: >
          {{ states('sensor.victron_battery_power_system')|is_number}}

Sensors used for battery in energy dashboard:

sensor:
  - platform: integration
    source: sensor.victron_battery_power_output
    name: Victron Battery Output Riemann
    method: left
    unit_prefix: k
    round: 3

  - platform: integration
    source: sensor.victron_battery_power_input
    name: Victron Battery Input Riemann
    method: left
    unit_prefix: k
    round: 3
1 Like

Thanks for this useful share !
Didn’t work for me as is though. You need to remove the quotes and use default values in floats for it to work :

    victron_battery_power_input:
      device_class: power
      friendly_name: "Battery Input Power"
      unit_of_measurement: "W"
      value_template: >
        {% if states('sensor.victron_battery_power_system')|float(0) >= 0 %}
        {{ states('sensor.victron_battery_power_system')|float(0) }}
        {% else %}
        0
        {% endif %}
      availability_template: >
        {{ states('sensor.victron_battery_power_system')|is_number}}
    victron_battery_power_output:
      device_class: power
      friendly_name: "Battery Output Power"
      unit_of_measurement: "W"
      value_template: >
        {% if states('sensor.victron_battery_power_system')|float(0) < 0 %}
        {{ -1 * states('sensor.victron_battery_power_system')|float(0) }}
        {% else %}
        0
        {% endif %}
      availability_template: >
        {{ states('sensor.victron_battery_power_system')|is_number}}

Welke sensoren van victron horen bij batterij? Ik heb het idee dat dit niet klopt.