Riemann integration for discharge and loading behave different

Somehow my Chrg_LoadCycles changed to 24?? Any suggestions?

What does the official webinterface state?

Have you found a solution in the meantime?

Hi,

sorry I totaly forgot about this thread.
No, I did not find any solution. Sometimes my charge counter justs resets. Maybe because It is not connected to the internet, idk.
If, one day, I want to know the cycles, I will calculate them out of my influxdb with some other values.

Do you have the same problem?

You are not the only ones. I am also having the problem of differing charge and discharge amounts, and therefore I am watching this thread…

Thanks for your great work. Could you also add a code which integrates SOC in % ?
That would be great

Thank you very much

How do you bring this figure (Chrg_LoadCycles) into an sensor?

I think there is something missing…

sensor:
  - platform: command_line
    name: Varta
    command: "curl -X GET http://Varta-IP/cgi/energy.js"

Have a look at my post from above

It explains how to parse the energy.js into sensor values. It does not include the loadCycles yet, but it’s basically the same procedure to get that as a sensor into home assistant. If you can’t figure it out with that code block and you still need help, let me know and I’ll have a look when I have some time :slight_smile:

Sure, that is done via Modbus.

Hopefully the plugin will be available soon: https://github.com/home-assistant/core/pull/63736

But for now you can use something like this:

modbus:
  - name: varta
    type: tcp
    host: <YOUR_VARTA_IP>
    port: 502
    retry_on_empty: true
    sensors:
      - name: "Varta battery SOC"
        unit_of_measurement: "%"
        address: 1068
        data_type: uint16
        slave: 255
        scan_interval: 1
      - name: "Varta battery state"
        address: 1065
        data_type: uint16
        slave: 255
        scan_interval: 1
      - name: "Varta battery capacity"
        unit_of_measurement: "10 Wh"
        address: 1071
        data_type: uint16
        slave: 255
        scan_interval: 30
      - name: "Varta battery active power"
        unit_of_measurement: "W"
        address: 1066
        slave: 255
        data_type: int16
        scan_interval: 1
      - name: "Varta battery energy counter"
        unit_of_measurement: "Wh"
        address: 1069
        count: 2
        state_class: total_increasing
        data_type: uint32
        swap: word
        slave: 255
        scan_interval: 30
      - name: "Varta battery grid power"
        unit_of_measurement: "W"
        address: 1078
        slave: 255
        data_type: int16
        scan_interval: 1

I have then used those values, the values from the energy.js and the values from my SolarEdge inverter to calculate all the needed values for the energy tab and for one of the lovelace views, which now looks something like this:

1 Like

Unfortunately I don’t get anything. By the way, I’ve got a Varta Pulse 6


The IP needs to be given without http:// as it is using the modbus protocol and not http :slight_smile:

for example

modbus:
  - name: varta
    type: tcp
    host: 192.168.0.54
    port: 502
    retry_on_empty: true

Update:
Note, that for the energy.js you need http://, as that one is served by a webserver on http.

:man_facepalming:t2: now it works

I am using the information given from dr-chef

Thanks a lot for you fantastic work!

Regarding this sensor:

sensor:
  - platform: rest
    name: varta_energy_totals_string
    scan_interval: 30
    resource: http://VARTAIP/cgi/energy.js
    value_template: "{{ value.replace(' ', '').replace('\n', '') }}"

Do get this data via resource: http://VARTAIP/cgi/energy.js is only possible if I log in via the webinterface (http://VARTAIP)…or what’s wrong in my setup?

<HTML><HEAD><TITLE>401Unauthorized</TITLE></HEAD><BODY>401Unauthorized</BODY></HTML>

Sadly Varta “updated” the software of the battery and decided to add an authentication to the local web-interface and remove the possibility to get the “total discharged” from the return values. So in order to get the data now, you need to use authentication and you cannot get the total discharged value anymore so you need to go for the Riemann integration as suggested in this thread.

Here is my snippet to get the enery_total_string as before but with authentication:

command_line:
  - sensor:
      name: varta_energy_totals_string
      scan_interval: 30
      command: |-
        user='MYUSER'; pass='MYPASSWORD'; ip='http://VARTAIP/cgi';\
        c=$(curl -X POST -ksc - $ip/login\?user\=$user\&password\=$pass -o /dev/null);\
        echo "${c}" | curl -ksb - $ip/energy.js
      value_template: "{{ value.replace(' ', '').replace('\n', '') }}"

Of course you need to replace MYUSER, MYPASSWORD and VARTAIP with the correct values for your setup. Login to the web-interface of your battery once before doing this so you know what values you need to fill.