Varta Storage Modbus workaround

THX!

I´ve got an “unavailable”. HAve you any idea?

Best regards, Martin.


it was more of an example.

what happens if u paste this into the in /developer-tools/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 %}

Just got my varta battery today. Has anybody ever polled /cgi/ems_data.js?
Seems like there is a lot of information in it. That data could be used in the integration.

Raw Data /cgi/ems_data.js

Zeit = "09.11.2023 18:19:23";
WR_Data = [0,-4000,4000,0,0,0,0,0,0,0,0,0,0,0,36,0,1,4,0,"255.255.255.255",0,14.9,0,0,0,0,120,1,0,1612317827,1342211584,0,0,0];
EMETER_Data = [5001,227,226,228,-32,-41,-167,-12,-30,-92,-34,-50,-191,0,0,1,4,9,7,4,9,7];
NA_Data = [5003,2275,2262,2275,2279,2272,2285,0.8,0];
Charger_Data = [[0,1,0,0,4823,0,626,298,120,26,29,31,0,0,0,0,0,0,349,0,1124564992,34819,0,18195,19,4,28,75,20,5,1860,0,
["LG_Neo",7,0,0,4830,0,20,1000,581,63,21,239,
  [[24608,0,0,0,0,0,49,1000,483,0,3444,3458,3450,63,21,3042,1052,239,236,237,0,0,600,600,29,0,2208056060,1396,56,46,10018,3451,3453,3445,3451,3452,3446,3449,3447,3450,3447,3444,3452,3449,3458]  ]
]
]
];

Raw Data /cgi/ems_conf.js:

WR_Conf = ["EMS PExtra","EMS UG","EMS OG","EMS Timer","PSoll","U Insel L1","U Insel L2","U Insel L3","I Insel L1","I Insel L2","I Insel L3","Temp L1","Temp L2","Temp L3","TBoard","FNetz","OnlineStatus","System State","SK","RB_IP","RCMU","UVcc","UZwk","UMp","Luefter","WR Ctrl","EMS Ctrl","EMS Mode","POpt", "BetrFlags1", "BetrFlags2","PMB","EMB","General State"];
Charger_Conf = ["Index","Enabled","SOC_GS","State","U","I","UOut","UCool","UVcc","THT","TTr","TBoard","PSoll","SOHCmax","SOHCuxtime","SOHDmax","SOHDuxtime","ErrorFlags","Temp1","Temp2","HelperFlags","BetrFlags","SteuerFlags","BattState","SVDFflags","RSOCmin","RSOCmax","SOCcut","DSOC_Thr1","DSOC_Thr2","SVDFtime","SVDFcnt1s","BattData"];
EMeter_Conf = ["FNetz","U_V_L1","U_V_L2","U_V_L3","Iw_V_L1","Iw_V_L2","Iw_V_L3","Ib_V_L1","Ib_V_L2","Ib_V_L3","Is_V_L1","Is_V_L2","Is_V_L3","Iw_PV_L1","Iw_PV_L2","Iw_PV_L3","Ib_PV_L1","Ib_PV_L2","Ib_PV_L3","Is_PV_L1","Is_PV_L2","Is_PV_L3"];
NA_Conf = ["FNetz","U_V_L1","U_V_L2","U_V_L3","U_I_L1","U_I_L2","U_I_L3","U N-PE","RCMU"];
Batt_Conf = ["LG_Neo","Type","Alarms_Rack","Warnings_Rack","U_Rack","I_Rack","SOC_Rack","SOH_Rack","UMax_Rack","IChrgLimit_Rack","IDiscLimit_Rack","Temp_Rack","ModulData"];
Modul_Conf = ["Status","Alarms_Modul","Warnings_Modul","Faults1_Modul","Faults2_Modul","IntErrors_Modul","SOC_Modul","SOH_Modul","U_Modul","I_Modul","UMin_Modul","UMax_Modul","UAvg_Modul","IChrgLimitBatt","IDiscLimitBatt","PChrgLimitBatt","PDiscLimitBatt","Temp1","Temp2","TempAvg","BalTarg","AnzCycles","CapDesign","CapUsable","CapRemain","SVDStat","PackSerNr","LifeEnergy","RackSOCmax","RackSOCmin","SwVersFull","CellVolt1","CellVolt2","CellVolt3","CellVolt4","CellVolt5","CellVolt6","CellVolt7","CellVolt8","CellVolt9","CellVolt10","CellVolt11","CellVolt12","CellVolt13","CellVolt14"];

Parsed:

 # Charger # 
01 Index: 0
02 Enabled: 1
03 SOC_GS: 0
04 State: 0
05 U: 4823
06 I: 0
07 UOut: 626
08 UCool: 298
09 UVcc: 120
10 THT: 26
11 TTr: 29
12 TBoard: 31
13 PSoll: 0
14 SOHCmax: 0
15 SOHCuxtime: 0
16 SOHDmax: 0
17 SOHDuxtime: 0
18 ErrorFlags: 0
19 Temp1: 349
20 Temp2: 0
21 HelperFlags: 1124564992
22 BetrFlags: 34819
23 SteuerFlags: 0
24 BattState: 18195
25 SVDFflags: 19
26 RSOCmin: 4
27 RSOCmax: 28
28 SOCcut: 75
29 DSOC_Thr1: 20
30 DSOC_Thr2: 5
31 SVDFtime: 1860
32 SVDFcnt1s: 0

 # Bat # 
02 Type: 7
03 Alarms_Rack: 0
04 Warnings_Rack: 0
05 U_Rack: 4830
06 I_Rack: 0
07 SOC_Rack: 20
08 SOH_Rack: 1000
09 UMax_Rack: 581
10 IChrgLimit_Rack: 63
11 IDiscLimit_Rack: 21
12 Temp_Rack: 239

 # WR # 
01 EMS PExtra: 0
02 EMS UG: -4000
03 EMS OG: 4000
04 EMS Timer: 0
05 PSoll: 0
06 U Insel L1: 0
07 U Insel L2: 0
08 U Insel L3: 0
09 I Insel L1: 0
10 I Insel L2: 0
11 I Insel L3: 0
12 Temp L1: 0
13 Temp L2: 0
14 Temp L3: 0
15 TBoard: 36
16 FNetz: 0
17 OnlineStatus: 1
18 System State: 4
19 SK: 0
20 RB_IP: 255.255.255.255
21 RCMU: 0
22 UVcc: 14.900000
23 UZwk: 0
24 UMp: 0
25 Luefter: 0
26 WR Ctrl: 0
27 EMS Ctrl: 120
28 EMS Mode: 1
29 POpt: 0
30 BetrFlags1: 1612317827
31 BetrFlags2: 1342211584
32 PMB: 0
33 EMB: 0
34 General State: 0

 # emeter # 
01 FNetz: 5000
02 U_V_L1: 227
03 U_V_L2: 227
04 U_V_L3: 228
05 Iw_V_L1: -32
06 Iw_V_L2: -40
07 Iw_V_L3: -166
08 Ib_V_L1: -13
09 Ib_V_L2: -30
10 Ib_V_L3: -95
11 Is_V_L1: -34
12 Is_V_L2: -50
13 Is_V_L3: -197
14 Iw_PV_L1: 0
15 Iw_PV_L2: 0
16 Iw_PV_L3: 1
17 Ib_PV_L1: 4
18 Ib_PV_L2: 10
19 Ib_PV_L3: 7
20 Is_PV_L1: 4
21 Is_PV_L2: 10
22 Is_PV_L3: 7

Hallo,
ich bin neu im Thema HA.

Ich hab die Datenpunkte von oben in die configuration.yaml eingefügt.

Die Abfolge wird auch mit einem grünen Harken als plausibel bestätigt.
Nach dem Speichern möchte ich nun den HA Neu starten. Dort kommt eine Fehlermeldung, dass die Confoguration.yaml falsch sein soll.

Kann mir jemand helfen?

It seems that not every Varta battery offers this access. At least I cannot access my Varta Neo Pulse like that.

Ersteinmal Respekt, dass du dich bereits an soetwas heran traust, wenn du neu bei HA bist.
Dennoch wird dir niemand bei so einer Anfrage helfen können, da du noch nicht einmal die Fehlermeldung mitgeschickt hast!

Ich könnte mir vorstellen, dass du eventuell das “count” Attribut bei den uint32-Einträgen entfernen musst. Hier wurde wohl mal etwas bezüglich Modbus aktualisiert. Genaueres kann dir aber die Fehlermeldung oder das Log geben.

Leider kann ich das Foto nicht hochladen, ich bekomme immer eine Fehlermeldung.

Daher nur der Text der Meldung:

Konfiguration konnte nicht neu geladen werden

Cannot quick reload all YAML configurations because the configuration is not valid: Invalid config for [modbus]: mb_varta_ACDC: 'count:

2’ cannot be combined with data_type: uint32 @ data’modbus’||0||‘sensors’]|11]. Got

{‘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’, ‘scan_interval’:

  1. mb_varta_timestamp: count: 2’ cannot be combined with data_type: uint32 @ datal’modbus’][0][‘sensors’][4]. Got {‘name’:

‘mb_varta_timestamp’, ‘slave’: 1, ‘address’:

1052, ‘count’: 2, 'data_type: ‘uint32’, ‘swap’:

‘word’, ‘precision’: 0, ‘scale’: 1, ‘scan_interval’:

15}. (See /config/configuration.yaml, line 13).

Kommentiere bei den beiden Einträgen die Zeile mit “Count” aus.

Meinst du einfach die Zeile „Count“ löschen? Oder was meinst du mit kommentieren?

Dann poste doch bitte den Modbus Auszug aus deiner configuration.yaml
Wir können dir so pauschal keine Hilfe geben.

Since 4am I cannot access the battery locally anymore. The integration tells me „failed to setup“
When I enter the ip I now have to enter a password. And /cgi/energy.js leads so a 401 not authorized. Was there an update?

Ok looks like they remove some data from energy.js …

EGrid_AC_DC = 1111111;
EGrid_DC_AC = 222222;
EWr_AC_DC = 333333;
Chrg_LoadCycles = [4];

EWr_DC_AC is now missing…

Hi,
ich habe den Code aus dem originalen Post bei mit in die configuration.yaml gepackt und die IP-Adresse entsprechend verändert. Leider funktioniert es bei mir nicht :frowning:

Diese Meldungen bekomme ich direkt im File Editor:

bad indentation of a mapping entry (183:12)

180 | unit_of_measurement: “W”
181 | sensor:
182 | - platform: template
183 | sensors:
------------------^
184 | mb_varta_status:
185 | friendly_name: "Varta Pulse Neo St …

Beim Überprüfung der Konfiguration bei den Entwicklerwerkzeugen kommt diese Meldung:

Konfigurationsfehler
Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/configuration.yaml”, line 183, column 12

Ich bin gestern erst von IO-Broker auf HA umgestiegen und deshalb evtl. auch noch ein Newbie :frowning: Vielleicht kann mir hier jemand helfen :slight_smile:

Grüße

Du hast den Code nicht richtig eingerückt.

Kannst du mir sagen wo ich genau etwas anpassen muss?

# Modbus Varta pulse neo
modbus:
  - name: "mb_varta"
    type: tcp
    host: 192.168.2.114 # 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 }}

Der Fehler liegt in deiner configuration.yaml
Das sagt dir auch die Fehlermeldung.

Ansonsten würde bei der Modbus Integration seitdem Post ein bischen was geändert. Darauf wird Home Assistant dich dann aber hinweisen.

HA.2401 seems to have deprecated “retries” - which now is fixed ot 3.
Until now I had to set retries to 6 to stop VARTA Element 6 to report “unavailable” all 60s. Now I am back to square 1 … following definition:

- name: VartaE6
  host: 192.168.2.5
  type: tcp
  port: 502
  delay: 2
  timeout: 10
  message_wait_milliseconds: 250
  retry_on_empty: true
  sensors:
    - name: "VE Battery SOC"
      unique_id: "VE6BSOC"
      data_type: uint16
      unit_of_measurement: "%"
      address: 1068
      slave: 1
      scan_interval: 60
      state_class: measurement
      device_class: battery

Error in log:

Logger: homeassistant.components.modbus.modbus
Source: components/modbus/modbus.py:375
Integration: Modbus (documentation, issues)
First occurred: 17:26:04 (5 occurrences)
Last logged: 17:31:04

Pymodbus: VartaE6: Error: device: 1 address: 1068 -> Modbus Error: [Connection] ModbusTcpClient(192.168.2.5:502): Connection unexpectedly closed 8.034706115722656e-05 seconds into read of 8 bytes without response from slave before it closed connection
Pymodbus: VartaE6: Error: device: 1 address: 1068 -> Modbus Error: [Connection] ModbusTcpClient(192.168.2.5:502): Connection unexpectedly closed 4.2438507080078125e-05 seconds into read of 8 bytes without response from slave before it closed connection

So, how to solve this now? Any Idea?

Besteht die Möglichkeit, dass du via Teamviewer dich mal auf meinen Rechner aufschaltest? Ich habe die configuration.yaml angepasst und bekomme endlich keine Fehlermeldungen mehr. Leider bekomme ich bei Varta Input Power sowie Output 0W angezeigt, obwohl in der App der Speicher geladen wurde. Ebenfalls funktionieren die Helfer nicht :frowning:

habe mir in den letzten Wochen HA auf dem Rasberry 5 zugelegt. Varta Pulse 3 hängt im Keller und im Netzwerk. Auch habe ich den Varta Storage konfiguriert bekommen…bekomme aber eine Error communicating with API Meldung…hat jemand eine Idee was da nicht funzt. Merci

Hi zusammen. Leider nur in Deutsch, mein Englisch wollt Ihr nicht lesen.
zum Problem Vartaspeicher:
meine Lösung, mit der ich endlich alle Werte erhalte. Varta ist mit Abfragen unter 1 sec. überfordert (Varta element und Vartalink)
#modbus:

  • name: speicher1
    type: tcp
    host: 192.168.0.61
    port: 502
    sensors:
    • name: laden1
      unit_of_measurement: “w”
      slave: 254
      address: 1066
      scan_interval: 1
      state_class: measurement
      scale: 1
      offset: 0
      precision: 1
      data_type: int16

    • name: batterie1
      unit_of_measurement: “%”
      address: 1068
      scan_interval: 1
      state_class: measurement
      scale: 1
      offset: 0
      precision: 1
      data_type: int16