Victron MQTT configurations

Add the following code to your mqtt.yaml file:

sensor:
  # Grid meter power
  - state_topic: "venus-home/N/c0619xxxxxx/grid/30/Ac/Power"
    name: "Grid power"
    unique_id: "grid_meter_power"
    device_class: power
    value_template: '{{ value_json.value | round(0) }}'
    unit_of_measurement: "W"
    icon: mdi:TransmissionTower

  # Victron alarms
  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/CellImbalance"
    name: "Alarm cell imbalance"
    unique_id: "alarm_battery_cell_imbalance"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}
      
  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/ChargeBlocked"
    name: "Alarm Charge blocked"
    unique_id: "alarm_battery_charge_blocked"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}
      

      
  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/DischargeBlocked"
    name: "Alarm Discharge blocked"
    unique_id: "alarm_battery_discharge_blocked"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}


  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighChargeCurrent"
    name: "Alarm high charge current"
    unique_id: "alarm_battery_high_charge_current"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighChargeTemperature"
    name: "Alarm high charge temperature"
    unique_id: "alarm_battery_high_charge_temperature"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighDischargeCurrent"
    name: "Alarm high discharge current"
    unique_id: "alarm_battery_high_discharge_current"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}
      
  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighTemperature"
    name: "Alarm high temperature"
    unique_id: "alarm_battery_high_temperature"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighVoltage"
    name: "Alarm high voltage"
    unique_id: "alarm_battery_high_voltage"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/InternalFailure"
    name: "Alarm internal failure"
    unique_id: "alarm_battery_internal_failure"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/LowChargeTemperature"
    name: "Alarm low charge temperature"
    unique_id: "alarm_battery_low_charge_temp"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/LowTemperature"
    name: "Alarm low temperature"
    unique_id: "alarm_battery_low_temp"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/LowVoltage"
    name: "Alarm low voltage"
    unique_id: "alarm_battery_low_voltage"
    value_template: >
      {% if value_json.value == 0 %}
        OK
      {% elif value_json.value == 1 %}
        Warning
      {% elif value_json.value == 2 %}
        Alarm
      {% endif %}

  # Victron Cerbo GX Serial number
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Serial"
    name: "Cerbo GX Serial number"
    unique_id: "victron_cerbo_serial"
    value_template: '{{ value_json.value }}'

  # Active SoC limit  
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Control/ActiveSocLimit"
    name: "Active SoC limit"
    unique_id: "active_soc_limit"
    device_class: battery
    unit_of_measurement: "%"
    value_template: '{{ value_json.value | round(0)}}'
    icon: mdi:battery-low

  # AC ActiveIN L1 Current
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/ActiveIn/L1/Current"
    name: "AC ActiveIn L1 Current"
    unique_id: "victron_activein_L1_current"
    device_class: current
    value_template: '{{ value_json.value |float(0)|round(2) }}'
    unit_of_measurement: "A"
    icon: mdi:power-socket-eu   

  # AC ActiveIN L1 Current
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/ActiveIn/L2/Current"
    name: "AC ActiveIn L2 Current"
    unique_id: "victron_activein_L2_current"
    device_class: current
    value_template: '{{ value_json.value |float(0)|round(2) }}'
    unit_of_measurement: "A"
    icon: mdi:power-socket-eu  

  # AC ActiveIN L1 Current
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/ActiveIn/L3/Current"
    name: "AC ActiveIn L3 Current"
    unique_id: "victron_activein_L3_current"
    device_class: current
    value_template: '{{ value_json.value |float(0)|round(2) }}'
    unit_of_measurement: "A"
    icon: mdi:power-socket-eu  

  # Grid Lost Status
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Alarms/GridLost"
    name: "Grid Lost Status"
    unique_id: "victron_grid_lost_status"
    value_template: > 
      {% if value_json.value == 0 %}
        Grid Connected
      {% elif value_json.value == 2 %}
        Grid Lost
      {% endif %}

  # Current Grid Setpoint
  - state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/AcPowerSetPoint"
    name: "Current grid setpoint"
    unique_id: "current_grid_setpoint"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"

    # Battery percentage
  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Soc"
    name: "Battery Percent"
    unique_id: "battery_percent"
    device_class: battery
    value_template: '{{ value_json.value | round(1) }}'
    unit_of_measurement: "%"
  
    # Battery percentage
  - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Soh"
    name: "Battery Health"
    unique_id: "battery_health"
    device_class: battery
    value_template: '{{ value_json.value | round(1) }}'
    unit_of_measurement: "%"

  # AC Loads
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/P"
    name: "AC Loads"
    unique_id: "ac_loads"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"
    icon: mdi:power-socket-eu
 
  # L1 Load
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L1/P"
    name: "L1 Load"
    unique_id: "L1_load"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"
    icon: mdi:power-socket-eu
 
  # L1 Output Voltage
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L1/V"
    name: "L1 Output Voltage"
    unique_id: "L1_Output_Voltage"
    device_class: voltage
    value_template: '{{ value_json.value|round(1) }}'
    unit_of_measurement: "V"
    icon: mdi:power-socket-eu

  # L1 Output frequency
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L1/F"
    name: "L1 output frequency"
    unique_id: "L1_output_frequency"
    device_class: frequency
    value_template: '{{ value_json.value|round(1) }}'
    unit_of_measurement: "Hz"
    icon: mdi:sine-wave    

  # L2 Load
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L2/P"
    name: "L2 Load"
    unique_id: "L2_load"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"
    icon: mdi:power-socket-eu    

  # L2 Output Voltage
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L2/V"
    name: "L2 Output Voltage"
    unique_id: "L2_Output_Voltage"
    device_class: voltage
    value_template: '{{ value_json.value|round(1) }}'
    unit_of_measurement: "V"
    icon: mdi:power-socket-eu

  # L2 Output frequency
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L2/F"
    name: "L2 output frequency"
    unique_id: "L2_output_frequency"
    device_class: frequency
    value_template: '{{ value_json.value|round(1) }}'
    unit_of_measurement: "Hz"
    icon: mdi:sine-wave    

  # L3 Load
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L3/P"
    name: "L3 Load"
    unique_id: "L3_load"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"
    icon: mdi:power-socket-eu    

  # L3 Output Voltage
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L3/V"
    name: "L3 Output Voltage"
    unique_id: "L3_Output_Voltage"
    device_class: voltage
    value_template: '{{ value_json.value|round(1) }}'
    unit_of_measurement: "V"
    icon: mdi:power-socket-eu

  # L3 Output frequency
  - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L3/F"
    name: "L3 output frequency"
    unique_id: "L3_output_frequency"
    device_class: frequency
    value_template: '{{ value_json.value|round(1) }}'
    unit_of_measurement: "Hz"
    icon: mdi:sine-wave

  # L1 Grid
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/Grid/L1/Power"
    name: "L1 Grid"
    unique_id: "L1_grid"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"
    icon: mdi:power-socket-eu 
    
  # L2 Grid
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/Grid/L2/Power"
    name: "L2 Grid"
    unique_id: "L2_grid"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"
    icon: mdi:power-socket-eu 

  # L3 Grid
  - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/Grid/L3/Power"
    name: "L3 Grid"
    unique_id: "L3_grid"
    device_class: power
    value_template: '{{ value_json.value }}'
    unit_of_measurement: "W"
    icon: mdi:power-socket-eu 

  # DC Loads
  - name: "DC Loads"
    device_class: power
    unique_id: "dc_loads"
    state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/System/Power"
    value_template: '{{ value_json.value|float(0)|round(0) }}'
    unit_of_measurement: "W"
    icon: mdi:power
    
  # Net Solar Production
  - name: "Current Solar Production"
    unique_id: "net_solar_production"
    device_class: power
    state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Pv/Power"
    value_template: '{{ value_json.value|float(0)|round(0) }}'
    unit_of_measurement: "W"
    icon: mdi:solar-power
  
  # Battery Voltage
  - name: "Battery Voltage"
    unique_id: "battery_voltage"
    device_class: voltage
    state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Battery/Voltage"
    value_template: '{{ value_json.value|float(0)|round(1) }}'
    unit_of_measurement: "V"

  # Battery Temp (If you have a temp sensor)
  - name: "Battery Temp"
    device_class: temperature
    unique_id: "battery_temperature"
    state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Battery/Temperature"
    value_template: '{{ ((value_json.value * 9/5) + 32) | round(0) }}'
    unit_of_measurement: "°F"

  # Net load going in/out of your battery
  - name: "Battery Load"
    unique_id: "battery_load"
    device_class: power
    state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Vebus/Power"
    value_template: '{{ value_json.value |float(0)|round(0) }}'
    unit_of_measurement: "W"
    
  # Net current going in/out of your battery
  - name: "Battery Current"
    unique_id: "battery_current"
    device_class: current
    state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Vebus/Current"
    value_template: '{{ value_json.value |float(0)|round(0) }}'
    unit_of_measurement: "A"

  # Temperature Multiplus II - Phase 1
  - name: "Temperature MPII #1"
    unique_id: "temp_mpII_1"
    device_class: temperature
    state_topic: "venus-home/N/c0619xxxxxx/temperature/25/Temperature"
    value_template: '{{ value_json.value |float(0)|round(0) }}'
    unit_of_measurement: "°C"

  # Temperature Multiplus II - Phase 2
  - name: "Temperature MPII #2"
    unique_id: "temp_mpII_2"
    device_class: temperature
    state_topic: "venus-home/N/c0619xxxxxx/temperature/26/Temperature"
    value_template: '{{ value_json.value |float(0)|round(0) }}'
    unit_of_measurement: "°C"

  # Temperature Multiplus II - Phase 3
  - name: "Temperature MPII #3"
    unique_id: "temp_mpII_3"
    device_class: temperature
    state_topic: "venus-home/N/c0619xxxxxx/temperature/27/Temperature"
    value_template: '{{ value_json.value |float(0)|round(0) }}'
    unit_of_measurement: "°C"

  # Temperature Multiplus II - Phase 3
  - name: "Pylontech battery power"
    unique_id: "pylontech_batt_power"
    device_class: power
    state_topic: "venus-home/N/c0619xxxxxx/battery/512/Dc/0/Power"
    value_template: '{{ value_json.value |round(0) }}'
    unit_of_measurement: "W"

  # Current State of your Inverter
  - name: "Inverter State"
    unique_id: "inverter_state"
    state_topic: "venus-home/N/c0619xxxxxx/system/0/SystemState/State"
    value_template: >
      {% if value_json.value == 0 %}
        Off
      {% elif value_json.value == 1 %}
        Low power
      {% elif value_json.value == 2 %}
        VE.Bus Fault condition
      {% elif value_json.value == 3 %}
        Bulk charging
      {% elif value_json.value == 4 %}
        Absorption charging
      {% elif value_json.value == 5 %}
        Float charging
      {% elif value_json.value == 6 %}
        Storage mode
      {% elif value_json.value == 7 %}
        Equalize
      {% elif value_json.value == 8 %}
        Passthru
      {% elif value_json.value == 9 %}
        Inverting
      {% elif value_json.value == 10 %}
        Assisting
      {% elif value_json.value == 252 %}
        External control
      {% elif value_json.value == 256 %}
        Discharging
      {% elif value_json.value == 257 %}
        Sustain
      {% elif value_json.value == 258 %}
        Recharging
      {% elif value_json.value == 259 %}
        Scheduled recharging
      {% else %}
        Error - No Data
      {% endif %}
  
  # Current state of your charge controller
  - name: "Solar Charger State"
    unique_id: "solar_charger_state"
    state_topic: "venus-home/N/c0619xxxxxx/solarcharger/289/State"
    value_template: >
      {% if value_json.value == 0 %}
        Off
      {% elif value_json.value == 2 %}
        Fault
      {% elif value_json.value == 3 %}
        Bulk
      {% elif value_json.value == 4 %}
        Absorption
      {% elif value_json.value == 5 %}
        Float
      {% elif value_json.value == 6 %}
        Storage
      {% elif value_json.value == 7 %}
        Equalize
      {% else %}
        Error - No Data
      {% endif %}

switch:
  #Multiplus Entladeleistung Begrenzen !Number
  - unique_id: multiplus_switch_discharge_power
    name: Inverter Power 
    command_topic: "venus-home/W/c0619xxxxxx/settings/0/Settings/CGwacs/MaxDischargePower"
    payload_on: '{"value": 1000}'
    payload_off: '{"value": -1}'
    state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/MaxDischargePower"
    value_template: >
      {% if value_json.value | int == -1 %}
        {% set state_limit = 'OFF' %}
      {% else %}
        {% set state_limit = 'ON' %}
      {% endif %}
      {{ state_limit }}
    state_on: 'ON'
    state_off: 'OFF'
    
    device: {
      identifiers: [
        "Victron Cerbo GX"
      ],
      manufacturer: "Victron Energy",
      model: "Cerbo GX",
      name: "Cerbo GX"}

  #Multiplus AC PV-Überschuss einspeisen
  - unique_id: multiplus_allow_ac_feed_in
    name: Multiplus allow AC feed in
    command_topic: "venus-home/W/c0619xxxxxx/settings/0/Settings/CGwacs/PreventFeedback"
    payload_on: '{"value": 0}'
    payload_off: '{"value": 1}'
    state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/PreventFeedback"
    value_template: "{{ value_json.value | int }}"
    state_on: '0'
    state_off: '1'
    
    device: {
      identifiers: [
        "Victron Cerbo GX"
      ],
      manufacturer: "Victron Energy",
      model: "Cerbo GX",
      name: "Cerbo GX"}

  #Multiplus DC PV-Überschuss einspeisen
  - unique_id: multiplus_allow_dc_feed_in
    name: Multiplus allow DC feed in
    command_topic: "venus-home/W/c0619xxxxxx/settings/0/Settings/CGwacs/OvervoltageFeedIn"
    payload_on: '{"value": 1}'
    payload_off: '{"value": 0}'
    state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/OvervoltageFeedIn"
    value_template: "{{ value_json.value | int }}"
    state_on: '1'
    state_off: '0'
    
    device: {
      identifiers: [
        "Victron Cerbo GX"
      ],
      manufacturer: "Victron Energy",
      model: "Cerbo GX",
      name: "Cerbo GX"}