Varta Storage Modbus workaround

Until the Varta Storage integration (Add vartastorage integration by Vip0r · Pull Request #63736 · home-assistant/core · GitHub) is accepted, you can access the Varta Storage via Modbus. The following snippets are for the Varta pulse neo.

# Modbus Varta pulse neo
modbus:
  - name: "mb_varta"
    type: tcp
    host: 192.168.40.4 # replace with your ip of the your varta
    port: 502
    delay: 1
    timeout: 3
    retries: 3
    retry_on_empty: true
    message_wait_milliseconds: 250
    sensors:
### EMS Software Version - not for Varta link
    - name: mb_varta_EMS
      slave: 1
      address: 1000
      count: 17
      data_type: string
      precision: 0
      scale: 1
### ENS Software Version - not for Varta link
    - name: mb_varta_ENS
      slave: 1
      address: 1017
      count: 17
      data_type: string
      precision: 0
      scale: 1
### Software Version - not for Varta link
    - name: mb_varta_software
      slave: 1
      address: 1034
      count: 17
      data_type: string
      precision: 0
      scale: 1
### Table version
    - name: mb_varta_table_version
      slave: 1
      address: 1051
      data_type: uint16
      precision: 0
      scale: 1
### timestamp -- not working
    - name: mb_varta_timestamp
      slave: 1
      address: 1052
      count: 2
      data_type: uint32
      swap: word
      precision: 0
      scale: 1
### Serial Number
    - name: mb_varta_serial
      slave: 1
      address: 1054
      count: 10
      data_type: string
      precision: 0
      scale: 1
### Number of Battery Modules installed
    - name: mb_varta_installed_batteries
      slave: 1
      address: 1064
      data_type: uint16
      precision: 0
      scale: 1
### State
    - name: mb_varta_state
      slave: 1
      address: 1065
      data_type: uint16
      precision: 0
      scale: 1
      unit_of_measurement: "State"
### Active Power - positive:charge / negative: discharge
    - name: mb_varta_active_power
      slave: 1
      address: 1066
      data_type: int16
      precision: 0
      scale: 1
      device_class: power
      unit_of_measurement: "W"
### Apparent Power - positive:charge / negative: discharge
    - name: mb_varta_apparent_power
      slave: 1
      address: 1067
      data_type: int16
      precision: 0
      scale: 1
      device_class: apparent_power
      unit_of_measurement: "VA"
### State of Charge
    - name: mb_varta_SOC
      slave: 1
      address: 1068
      data_type: uint16
      precision: 0
      scale: 1
      device_class: battery
      unit_of_measurement: "%"
### energy counter AC->DC - not sure if correct
    - name: mb_varta_ACDC
      slave: 1
      address: 1069
      count: 2
      data_type: uint32
      swap: word
      precision: 0
      scale: 1
      device_class: energy
      unit_of_measurement: "Wh"
      state_class: total_increasing
### Installed capacity
    - name: mb_varta_capacity
      slave: 1
      address: 1071
      data_type: uint16
      precision: 0
      scale: 10
      device_class: energy
      unit_of_measurement: "Wh"
### Grid Power
    - name: mb_varta_grid_power
      slave: 1
      address: 1078
      data_type: int16
      precision: 0
      scale: 1
      device_class: power
      unit_of_measurement: "W"
sensor:
- platform: template
    sensors:
      mb_varta_status:
        friendly_name: "Varta Pulse Neo Status"
        value_template: >-
          {% set mapper =  {
              '0' : 'Busy',
              '1' : 'Run',
              '2' : 'Charge',
              '3' : 'Discharge',
              '4' : 'Standby',
              '5' : 'Error',
              '6' : 'Service',
              '7' : 'Islanding' } %}
          {% set state =  states.sensor.mb_varta_state.state %}
          {{ mapper[state] if state in mapper else 'Unknown' }}
# Varta input/output
template:
  - sensor:
    - name: "Varta Input Power"
      unit_of_measurement: "W"
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.mb_varta_active_power') | float(0) >= 0 %}
        {% set varta_in = states('sensor.mb_varta_active_power') | float(0) %}
        {% else %}
        {% set varta_in = 0 %}
        {% endif %}
        {{ varta_in }}
        
  - sensor:
    - name: "Varta Output Power"
      unit_of_measurement: "W"
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.mb_varta_active_power') | float(0) <= 0 %}
        {% set varta_out = states('sensor.mb_varta_active_power') | float(0) *-1 %}
        {% else %}
        {% set varta_out = 0 %}
        {% endif %}
        {{ varta_out }}

Do not forget the two corresponding helper to get the input and output into the Home Assistant energy dashboard:

At the end, it can look like this:

Here are the two screenshots of the Varta Modbus specification in case you have another battery and you want to read more or other data:


Please feel free to comment any improvement you see.

2 Likes

for Varta backup element

# installed capacity - sum of all installed battery modules
    - name: "Varta battery capacity"
      unit_of_measurement: "10 Wh"
      address: 1071
      data_type: uint16
      slave: 1
      scan_interval: 30
      device_class: energy

Thanks for your feedback.
The register 1071 is already included and is available for all models.

I used the scale factor to have Wh as a standard unit.

By the way, does anyone know how to implement the registers 2066 to 2078 as scale factors for the corresponding registers?

And does anyone know how to get the number of cycles? I can’t figure out which values to use for calculation if I compare the results with the values from the Varta GUI.

könntest du mir einmal zeigen wie ich die Helfer einstellen muss, bzw wie ich die Minuswerte umwandle um die geeigneten Entitäten für das energie Dashboard zu bekommen.

could you show me how I have to set the helpers or how I convert the minus values ​​to get the appropriate entities for the energy dashboard

Kopiere den dritten Code oben #Varta Input/Output. Der macht dir die Aufteilung in Läden und Entladen.

Dann erstellt du dir für beide einen Helfer unter Dienste & Geräte bei Helfer.
Da wählst du Integration - Riemann aus und dann die beiden neuen Sensoren. Einfach auf Linke Integrationsmethode stellen und den Rest lassen.

Ah ja super vielen Dank, gibt es das ganze auch für den Netzbezug oder muss ich da einfach nur die Namen und Entitäten von Varta input/output ändern?

Zu dem hätte ich noch eine frage, ob es möglich ist die Daten der Solaranlage welche bei mir nur der Speicher misst mit einzubinden da mein Wechselrichter dieses nicht kann, Im Varta Dashboard kann ich diese allerdings sehen.

Gemäß Modbus Spezifikation von Varta kann das nur der Varta Pulse mit dem Register 1102 und wenn ein PV Sensor angeschlossen ist.
Da stellt sich die Frage, wo dein Speicher die Info herbekommt. Unter Umständen auch per Modbus vom PV Wechselrichter. Da solltest du Mal nach einer Integration schauen.

Der Wechselrichter ist gar nicht mit dem Wlan verbunden da die SSID keine Sonderzeichen (Leertaste) beinhalten darf und ich das Netzwerk nicht umbenenne möchte/kann.

Für den Netzbezug musst du die Templates nochmal verwenden, umbenennen und den Sensor auf mb_varta_grid_power ändern.

Wo bekommt der Varta denn den Wert der PV her?
Da musst du auf dem Varta GUI, nicht der App schauen.

Hab jetzt ein bisschen gesucht und herausgefunden das der Speicher den Strom über 2 Varta Splitcore Sensor 3-Phasig abgreift und somit weis wie viel eingespeist und erzeugt wird. Weis jetzt nur noch nicht wie ich diesen auslesen kann aber werde dann mal weiter suchen.

Dann würde ich Mal probieren das Register 1102 auszulesen, auch wenn es nur bei einem Varta Pulse Daten enthalten soll.

Varta stellt leider nicht alle Daten offiziell per Modbus zur Verfügung.

Should there be a Varta integration? Is this ready and just waiting to be taken in home assistant?

image
habe das ganze jetzt einmal hinzugefügt und leider keine Daten erhalten. :frowning:
werde dann wohl erstmal weiterschauen und nochmal Varta selbst eine Email schreiben ob es möglich ist die Daten dieses Sensors zu nutzen.

Deine Implementierung sieht jedenfalls richtig aus.
Warum Varta nicht alle Werte per Modbus zur Verfügung stellt bleibt offen.
Ich würde mir hier leider nicht zu große Hoffnungen machen.
Ich hatte Varta mal bezüglich der Ladezyklen angeschrieben. Außer einem Danke habe ich Nichts weiter erhalten. Allerdings weiß ich auch nicht, welchen Regularien die Software unterliegt. Da können noch weitere Kosten für die Hersteller anfallen als nur die reine Entwicklung.

Vielleicht frage ich auf deutsch… soll es zukünftig eine Integration geben ? Habe ich das richtig gelesen?

Siehe den original post.
Da ist sogar der Link zum repository von Vip0r. Leider dauert die Freigabe schon sehr lange.
Daher dieser thread als workaround bis zur Freigabe.

Allerdings gehe ich nicht davon aus, dass dadurch mehr Sensoren zur Verfügung stehen werden.

For the PV Excess Control Automation I need these entities, but how can I create them with the Varta data?

Load Power
Sensor which contains your current load power (combined household appliance consumption without home battery charging consumption) in watts

Combined Import/Export Power
Sensor which contains both, your current import power from the grid (positive values) and your current export power to the grid in watts (negative values)

@nuki47 the load power should be a +/- of the grid power sensor and the active power sensor.