Victron integration with ESP32 - Solar works but not the BMV

Hello,

New to the forums as well as home assistant. It’s absolutely fantastic and i’m loving it! So thanks everyone in the community.

I found this GitHub - Fabian-Schmidt/esphome-victron_ble: Use official Victron BLE endpoint for fetching data from Victron devices via Bluetooth LE via ESPHome.
and had pretty good success. Except for my Victron BMV-712 Smart

I’m trying to get my “batteries” into Home assistant with no luck.

The Setup:
3 Victron MPPT solar charge controllers. (StBd Solar, Port Solar, Arch Solar)
1 BMV-712 Smart (essentially the “Victron Smart Shunt”)
Using EPSHome/ESP32.

Under the Energy tap i’m able to add the charge controllers under the “solar” section. However I can’t seem to add the battery, it’s not really showing what i need? I think? Like what entities should i be using or am i wrong in thinking I can integrate the BMV as the battery?

Here is the code i’m using:

# All Sensors (Merged)
sensor:
  # ArchSolar Sensors
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "Battery Voltage (ArchSolar)"
    type: BATTERY_VOLTAGE
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "Battery Current (ArchSolar)"
    type: BATTERY_CURRENT
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "Yield Today (ArchSolar)"
    type: YIELD_TODAY
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "PV Power (ArchSolar)"
    id: pv_power_arch
    type: PV_POWER
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "Load Current (ArchSolar)"
    type: LOAD_CURRENT
  - platform: integration
    name: "Solar Energy Produced (ArchSolar)"
    sensor: pv_power_arch
    unit_of_measurement: "Wh"
    time_unit: h 
    accuracy_decimals: 2
    state_class: total_increasing
    device_class: energy

  # PortSolar Sensors
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "Battery Voltage (PortSolar)"
    type: BATTERY_VOLTAGE
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "Battery Current (PortSolar)"
    type: BATTERY_CURRENT
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "Yield Today (PortSolar)"
    type: YIELD_TODAY
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "PV Power (PortSolar)"
    id: pv_power_port
    type: PV_POWER
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "Load Current (PortSolar)"
    type: LOAD_CURRENT
  - platform: integration
    name: "Solar Energy Produced (PortSolar)"
    sensor: pv_power_port
    unit_of_measurement: "Wh"
    time_unit: h 
    accuracy_decimals: 2
    state_class: total_increasing
    device_class: energy

  # StBdSolar Sensors
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "Battery Voltage (StBdSolar)"
    type: BATTERY_VOLTAGE
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "Battery Current (StBdSolar)"
    type: BATTERY_CURRENT
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "Yield Today (StBdSolar)"
    type: YIELD_TODAY
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "PV Power (StBdSolar)"
    id: pv_power_stbd
    type: PV_POWER
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "Load Current (StBdSolar)"
    type: LOAD_CURRENT
  - platform: integration
    name: "Solar Energy Produced (StBdSolar)"
    sensor: pv_power_stbd
    unit_of_measurement: "Wh"
    time_unit: h 
    accuracy_decimals: 2
    state_class: total_increasing
    device_class: energy

  # VictronBMV
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "Time remaining"
    type: TIME_TO_GO
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "Battery Voltage"
    type: BATTERY_VOLTAGE
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "Starter Battery Voltage"
    # AUX_VOLTAGE or MID_VOLTAGE or TEMPERATURE.
    # Depending on configuration of SmartShunt.
    type: AUX_VOLTAGE
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "Battery Current"
    type: BATTERY_CURRENT
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "Consumed Ah"
    type: CONSUMED_AH
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "State of charge"
    type: STATE_OF_CHARGE
  
# All Binary Sensors (Merged)
binary_sensor:
# Arch Solar
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "MPPT is in Fault state (ArchSolar)"
    type: DEVICE_STATE_FAULT
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "MPPT has Error (ArchSolar)"
    type: CHARGER_ERROR
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "MPPT in FLOAT (ArchSolar)"
    id: mppt_in_float_arch
    type: DEVICE_STATE_FLOAT
# Port Solar
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "MPPT is in Fault state (PortSolar)"
    type: DEVICE_STATE_FAULT
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "MPPT has Error (PortSolar)"
    type: CHARGER_ERROR
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "MPPT in FLOAT (PortSolar)"
    id: mppt_in_float_port
    type: DEVICE_STATE_FLOAT
# StBd Solar
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "MPPT is in Fault state (StBdSolar)"
    type: DEVICE_STATE_FAULT
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "MPPT has Error (StBdSolar)"
    type: CHARGER_ERROR
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "MPPT in FLOAT (StBdSolar)"
    id: mppt_in_float_stbd
    type: DEVICE_STATE_FLOAT
#Victron BMV
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "Battery has Alarm"
    type: ALARM


# All Text Sensors (Merged)
text_sensor:
# Arch Solar
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "MPPT state (ArchSolar)"
    type: DEVICE_STATE
  - platform: victron_ble
    victron_ble_id: ArchSolar
    name: "MPPT Error reason (ArchSolar)"
    type: CHARGER_ERROR
# Port Solar
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "MPPT state (PortSolar)"
    type: DEVICE_STATE
  - platform: victron_ble
    victron_ble_id: PortSolar
    name: "MPPT Error reason (PortSolar)"
    type: CHARGER_ERROR
# StBd Solar
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "MPPT state (StBdSolar)"
    type: DEVICE_STATE
  - platform: victron_ble
    victron_ble_id: StBdSolar
    name: "MPPT Error reason (StBdSolar)"
    type: CHARGER_ERROR
# Victron BMV
  - platform: victron_ble
    victron_ble_id: VictronBMV
    name: "Battery Alarm reason"
    type: ALARM_REASON

I dont use this integration, but I will try to help you anyway as noone else replied.
From my understanding you need BATTERY_POWER (Watt) and use a riemann sum/intergration of that sensor for the kWh.
As the battery power may be negative you also need to differentiate between import and export with a template sensor like this:

{% if is_number(states('sensor.BATTERY_POWER')) and states('sensor.BATTERY_POWER') | float(0) > 0 %}
    {{(states('sensor.BATTERY_POWER') | float(0)) | round (3) }}
{% else %}
    {{(states ('0.0') | float(0)) |round(3) }}
{% endif %}

and < 0 for whatever minus power is defined. Then you have two Watt sensors (state class: measurement, device class: power) of which you need to create the riemann sum. The riemanns are the sensors you need to select for your energy dashboard.

The Smart Shunt doesn’t output a Watt figure, but rather a Current in Amps. You would have to convert that to Watts.