Varta Storage Modbus workaround

Load Power > must not be negative! is this possible? how can I get this data?

All required information are already posted in the original post.

I would say you need something like this:

Varta input/output

template:
  - sensor:
    - name: "Grid Power"
      unit_of_measurement: "W"
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.mb_varta_grid_power') | float(0) <= 0 %}
        {% set grid_in = states('sensor.mb_varta_grid_power') | float(0) *-1%}
        {% else %}
        {% set grid_in = 0 %}
        {% endif %}
        {{ grid_in }}

That should give you only your grid consumption. Assuming you do not charge your Varta from the grid.

Hi,

thanks for the work around scripts which work well with Varta Element S2.

As recommended above, I created the Riemann helper and now after three days I notice that Varta Input Power is twice the amount of the Varta Output Power after the battery is fully charged every other day. I’m wondering if this means that the system has only a 50-60% efficiency (I would have expected something in the range of 80-85%) or is there a bug in the sensor formula above (counting the values twice). Has someone else experienced such a huge drift in the input & output values?

Thanks
tmb

Hallo maltejarr,

ich bin ein Anfänger im Bereich HA, und auf der Suche nach eine Einbindung für einen Varta Speicher auf deinen Workaround gestossen. Leider fehlt mir etwas der Durchblick, welche Code Segment ich wo einfügen soll. Könntest Du das noch beschreiben?
Wäre Dir sehr dankbar.

Ich empfehle Google Suche mit den jeweiligen Schlagworten Templates, Sensor und Modbus mit Home Assistant, oder die Home Assistant Dokumentation.

Die Datei configuration.yaml ist das Wichtigste.

If you divide Output/Input it should give you the efficiency.
My Varta Pulse Neo comes to roughly 77%.
You can crosscheck via the Varta App and divide the average output/input over the last year.

It will vary depending on your production and usage over the days.

image
habe jetzt schon alles zweimal gecheckt und das Problem nicht gefunden warum ich keine Daten zur Netzeinspeisung bekomme, sehr ihr den Fehler ?

image

image
und ich kann wie man hier sieht die Daten empfangen lediglich die Netzeinspeisung Entität geht nicht

Ohne deine gesamte Modbus Konfiguration zu kennen, vermute ich Mal, dass du zweimal varta_in und varta_out definiert hast.
Mach Mal aus varta_in varta_grid_in und respektive für varta_out, bei der Aufteilung für Grid.

please can you share the template yaml code for the efficiency?

- sensor:
    - name: "Varta Efficiency"
      unit_of_measurement: "%"
      state: >
        {% set varta_efficiency = states('sensor.varta_output_energy') | float(0) / states('sensor.varta_input_energy') | float(0) %}
        {{ varta_efficiency }}

könntest du noch einmal deinen yaml Code für den Netzbezug/Netzeinspeisung Teilen, habe alles probiert, aber den Fehler leider nicht gefunden und würde das einem mit deinem abgleichen.

Für den Netzbezug habe ich es bereits oben gepostet.

The sensor.mb_varta_active_power seems not very stable, mostly “unavailable” and I have no glue what’s the reason?

Any suggestions?

modbus:
  - name: mb_varta       ### or whatever name
    type: tcp
    host: 192.168.100.101       ### ip/hostname your inverter has
    port: 502
    delay: 2 
    timeout: 5 
    retries: 5 
    retry_on_empty: true
    message_wait_milliseconds: 250
    sensors:
### 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"

I’ve been having nothing but trouble with modbus lately. My configuration worked fine for years and now it suddenly stopped working. So far, nobody will confirm or deny whether modbus support has been removed???

I had some unavailability issues too for some days.
I don’t know if it is linked to updates. But as far as I remember, there have been updates related to Modbus.

My personal suggestion is to give the Varta a static IP or at least a fixed one. Theoretically your Varta might get another IP if your router restarts. At least your IP seems to be a dynamic one.

A restart of Home Assistant got the values back for me.

Hallo,

ich bin auch neu hier und versuche es erstmal auf deutsch. Meinen Speicher habe ich soweit vorbereitet und nun wollte ich auch die Anzeige wie im Energie Dashboard, aber meine Templates gehen nicht.

# Modbus Varta pulse neo
  - name: "mb_varta"
    type: tcp
    host: 192.168.2.36 # replace with your ip of the your varta
    port: 502
    delay: 1
    timeout: 3
    retries: 3
    message_wait_milliseconds: 250
    sensors:
    - name: mb_varta_active_power #Active Power - positive:charge / negative: discharge
      slave: 1
      address: 1066
      data_type: int16
      precision: 0
      scale: 1
      device_class: power
      unit_of_measurement: "W"
      
    - name: mb_varta_apparent_power # Apparent Power - positive:charge / negative: discharge
      slave: 1
      address: 1067
      data_type: int16
      precision: 0
      scale: 1
      device_class: apparent_power
      unit_of_measurement: "VA"
      
    - name: mb_varta_SOC # State of Charge
      slave: 1
      address: 1068
      data_type: uint16
      precision: 0
      scale: 1
      device_class: battery
      unit_of_measurement: "%"
      
    - name: mb_varta_grid_power # Measured at Household grid connection point
      slave: 1
      address: 1078
      data_type: int16
      precision: 0
      scale: 1
      device_class: power
      unit_of_measurement: "W"

Template:

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 }}

Funktioniert es gerade nicht, dass das Laden/Entladen angezeigt wird? Hab eine Varta Pulse Neo.

Der Sensor mb_varta_grid_power zeigt mir Positive und Negative Werte an:

Die Helfer habe ich beide Angelegt als Integration - Riemann Summenintegralsensor und beide als Linke Riemannsche Summe als Integrationsmethode hinterlegt. Den Rest habe ich so gelassen.
Der Varta Input Energy Helfer zeigt mir was an.

Der Varta Output Energy Helfer zeigt nichts an Nicht verfügbar.

I need some help…newbie!

I have calculated the remaining charging and discharging time in my Gira system at the current performance. Unfortunately I can’t get any further with HA in the last step.

I need an entity “Varta Time Remaining” and want it at
the status “2=Charge” with the state of “mb_varta_charging_time” and with the status “3=Discharge” with the status “mb_varta_discharging_time”.

A “0” would be great if there is neither charging nor discharging!

Can you help me? Maybe someone else needs this, it always helped me to see if I could get through the night.

Thank you very much, Martin.

    # Varta Discharging Time KWh
  - sensor:
    - name: "Varta Discharging Time"
      unique_id: "mb_varta_discharging_time"
      device_class: energy
      state_class: measurement
      unit_of_measurement: "h"
      state: >
        {{ ((float(states('sensor.mb_varta_discharging_energy'))) / 1000) / ((float(states('sensor.mb_varta_active_power'))) / 1000) | round (1) }}

    # Varta Charging Time KWh
    - name: "Varta Charging Time"
      unique_id: "mb_varta_charging_time"
      device_class: energy
      state_class: measurement
      unit_of_measurement: "h"
      state: >
        {{ ((float(states('sensor.mb_varta_charging_energy'))) / 1000) / ((float(states('sensor.mb_varta_active_power'))) / 1000) | round (1) }}



sensor:
  - platform: template
    sensors:
      mb_varta_status:
        friendly_name: "Varta 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' }}

use a template sensor:

for example like this:

sensor:
  - platform: template
    sensors:
      varta_time_remaining:
        friendly_name: "Varta Time Remaining"
        unit_of_measurement: "h"
        icon_template: mdi:clock

        value_template: >-
          {% set status = states('sensor.mb_varta_status') %}
          {% set charging_time = states('sensor.mb_varta_charging_time') | float %}
          {% set discharging_time = states('sensor.mb_varta_discharging_time') | float %}
          
          {% if status == 'Charge' %}
            {{ charging_time }}
          {% elif status == 'Discharge' %}
            {{ discharging_time }}
          {% else %}
            0
          {% endif %}