Energy Dashboard gone crazy after activation of battery (Kostal Plenticore, KSEM, BYD)

Hi all,
I am really desperate since some hours, since my entire Energy dashboard has fallen apart and is showing bogus numbers after the activation of the BYD battery in my Kostal inverter.

Let me try to describe the situation:

  1. The solar roof is working since early December, but the two-way meter and the battery were only installed today.
  2. I have a Kostal Plenticore inverter, and I have a Kostal Smart Energy Meter (KSEM) installed. Both are connected through a direct connection (Modbus?), and both are separately accessible in my LAN.
  3. Until yesterday, everything was working fine. I have switched of the inverter after sunset since the workers wanted to come early.
  4. I now wanted to re-configure the Energy Dashboard, but all the charts do not make sense anymore.

Up to now, I was using those sensors:

  • plenticore_Home Consumption from Grid Total
  • plenticore_Energy Yield Total
  • netzeinspeisung_energie_ksem (from configuration.yaml: modbus configuration for the KSEM gear)

I now have several findings, that I do not understand in the Energy dashboard:

  1. Which are the appropriate sensors for the power from the grid and the discharge to the grid?
  2. Do I have to configure my home consumption with a series of individual sensors from the Plenticore inverter? (home_consumption_from_grid, home_consumption_from_battery and home_consumption_from_pv?)
  3. Is the battery charging part of the solar yield that I harvest from my roof? – My inverter has a higher yield in its display than HA. I am calculation numbers back & forth, and the data does not match.
  4. What is the difference between plenticore_Energy Yield Total and plenticore_Energy PV1_Total? – I was assuming that Energy_Yield_Total would be the sum of my strings PV1 and PV2, but this again does not match.
  5. Finally: Do I have to restart HA to rebuild the dashboard with different sensors? – I do assume that I do not completely screw up my data, since the sensors are (hopefully) stored separately. Or can I break my data with trial & error?

Thanks a lot in advance.

Best regards,
Marcus

This is how it looks over night. This is utterly wrong, and my home consumption is accounted three times.

I have now taken the battery out of the configuration, and only use the KSEM measures, which is positioned between the official meter and my house installation. This cannot be worng.
Et voila, now the numbers are correct:

  • no triple-counting anymore
  • power consumption in the expected range

Downside: I see the supply from battery as “solar power”.
Is this correct for DC-installed batteries?

I’ve come in to post a similar issue, that I’m have had with my Growatt system + battery setup. Like yours I’m getting duplicate values, as the system shows the ‘consumption’ as a total that includes power drawn from the battery and then I get the discharge value added to the total for that hour. So the Energy dashboard needs to remove the battery discharge amount from the consumption amount to generate the ‘total’ usage for that period + costs.

I too am wondering how people are getting the correct values when using all data points, input, output, solar & battery.

1 Like

I am glad that I am not alone. But the Kostal integration is widely used, I really cannot imagine that all others do not have a battery. :slight_smile:

What I realize from playing around: The “home consumption” seems to be calculated. When I add more sensors to the “solar” section whilst keeping the discharge to grid, the home consumption goes up.
And all those calculations never match what my inverter is calculating.

But it is tricky to do the debugging since everything is floating and the dashboard is static. I always look at this short after the top of the hour. :frowning:

Hi! I have Plenticore plus 10, KSEM and BYD 13.8KWH HVM. Kostel Plenticore Plus 10 has native integration with HA and provides almost all sensors natively.

Heres what i’ve set up for myself.

As i want to have exact power consumption and feed in, so by phase ive set up KSEM in configuration.yaml

modbus:
  - name: "KSEM" 
    type: tcp
    host: IPHERE
    port: 502
    sensors:
    - name: networkreference_power_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 0
      scan_interval: 10
      count: 2
      input_type: holding
      data_type: uint32

    - name: gridfeed_power_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 2
      scan_interval: 10
      count: 2
      input_type: holding
      data_type: uint32

    - name: networkreference_energy_ksem
      slave: 1
      scale: 0.0001
      precision: 3
      address: 512
      scan_interval: 60
      count: 4
      input_type: holding
      data_type: uint64
      device_class: energy
      state_class: total_increasing
      unit_of_measurement: kWh

    - name: gridfeed_energy_ksem
      slave: 1
      scale: 0.0001
      precision: 3
      address: 516
      scan_interval: 60
      count: 4 
      input_type: holding
      data_type: uint64
      device_class: energy
      state_class: total_increasing
      unit_of_measurement: kWh

    - name: L1_in_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 40
      scan_interval: 10
      count: 2
      input_type: holding
      data_type: uint32

    - name: L1_out_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 42
      scan_interval: 10
      count: 2
      input_type: holding
      data_type: uint32

    - name: L2_in_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 80
      scan_interval: 10
      count: 2
      input_type: holding
      data_type: uint32

    - name: L2_out_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 82
      scan_interval: 10
      count: 2 
      input_type: holding
      data_type: uint32

    - name: L3_in_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 120
      scan_interval: 10
      count: 2
      input_type: holding
      data_type: uint32

    - name: L3_out_ksem
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: W
      scale: 0.1
      address: 122
      scan_interval: 10
      count: 2
      input_type: holding
      data_type: uint32

For grid consumption i have “Energy IN KSEM” which is a meter based on L1+L2+L3 IN sum and for return to grid i have “Energy OUT KSEM” which is a meter for L1+L2+L3 OUT, i used helper for it, naming the sums as “IN” and “OUT”. I want to measure across phases, as i get charged by phase (so if i have load that exceeds my solar or battery output on one phase i get charged for it).

Then i used helper again, using " Add Riemann sum integral sensor" with both “IN” and “OUT” separately, naming it “IN energy” and “OUT energy” (for riemann settings i used “left”, metric prefix “k” and unit of time “H”). Now you have kWh.

Then i used helper again for utility meter, creating “Energy IN KSEM” with “IN energy” and “Energy OUT KSEM” with “OUT energy”.

For solar input i used Kostal Plenticore integration and “_energy_pv1_total” and “_energy_pv2_total”.
For battery input i used Kostal Plenticore integration and “_battery_charge_from_PV” and “_home_consumption_from_PV”.

The resulting dashboard.

1 Like

If anyone has any ideas as to how it would be possible to force Plenticore 10 with BYD HVM to charge for automation in home assistant, then i’d gladly take any input on this.

I’ve resolved this issue for myself. It turns out that although register 1034 accepts positive values (forced discharging) as absolute ( so 1-3500 written will correspond to 1-3500W of forced discharge from battery in my case, as it’s BYD HVM13.8 max discharge) it wants negative values (forced charging of battery) to be defined as percentages of battery specific maximum charge.

So if anyone wants to charge BYD HVM 13.8 at anything between 1-100% you have to first multiply it by 100 and then convert.

For each value:

  1. Convert the desired float value to IEEE 754 float32 binary representation.
  2. Extract the two 16-bit words from the 32-bit representation.
  3. Convert those 16-bit values to decimal.

Example:
10%
For -1000 : Hex: c4800000
Words: c480 and 0000
Decimal: 50240 and 0

100%
For -10000 : Hex: c5600000
Words: c560 and 0000
Decimal: 50528 and 0

and to make everyones, including future me, life easier:
(save these each as a separate script that you can run manually to test)


alias: PC10-BYDHVM charge 50%
sequence:
  - service: modbus.write_register
    data:
      hub: PLENTICORE10
      address: 1034
      unit: 71
      value:
        - 0
        - 50408
mode: single

alias: PC10-BYDHVM charge 60%
sequence:
  - service: modbus.write_register
    data:
      hub: PLENTICORE10
      address: 1034
      unit: 71
      value:
        - 0
        - 50432
mode: single

alias: PC10-BYDHVM charge 70%
sequence:
  - service: modbus.write_register
    data:
      hub: PLENTICORE10
      address: 1034
      unit: 71
      value:
        - 0
        - 50456
mode: single

alias: PC10-BYDHVM charge 80%
sequence:
  - service: modbus.write_register
    data:
      hub: PLENTICORE10
      address: 1034
      unit: 71
      value:
        - 0
        - 50480
mode: single

alias: PC10-BYDHVM charge 90%
sequence:
  - service: modbus.write_register
    data:
      hub: PLENTICORE10
      address: 1034
      unit: 71
      value:
        - 0
        - 50504
mode: single

alias: PC10-BYDHVM charge 100%
sequence:
  - service: modbus.write_register
    data:
      hub: PLENTICORE10
      address: 1034
      unit: 71
      value:
        - 0
        - 50528
mode: single
2 Likes

can you help me with the value of a hvs 7,7?

hub: Kostal-BYD
address: 1034
unit: 71
value:

  • 0
  • 50528

at the moment i have this…

Hello, I have a question about the Home Battery Storage section of the dashboard, specifically regarding “_battery_charge_from_PV”. It could be that the battery is not charged from PV but from the grid. This will not be included and shown as house used energy, right?

Ok I experimented a little bit for myself and cannot really reproduce your described behaviour. But you got me on the right track.

Kostal has different modbus registers for absolute and relative setpoints described in their manual, too

so absolute charge power register is 1026 (ac) and 1024 (dc); relative charge power is 1030 (ac) and 1036 (dc), accordingly.

On my PlenticoreBi I use register 1030 with value -100 (should refer to -100% according to their manual)

data:
  address: 1030
  slave: 71
  hub: PlenticoreBi
  value:
    - 0
    - 49864
action: modbus.write_register

btw your manual for conversion works perfectly on chatgpt, thanks for that

For each value:

  1. Convert the desired float value to IEEE 754 float32 binary representation.
  2. Extract the two 16-bit words from the 32-bit representation.
  3. Convert those 16-bit values to decimal.

Anyhow, if you set like -10000 on absolute charge power it is literally 10kW, but the Kostal Plenticore seems to have a safety feature to only use the maximum possible load power for your set up.
second: for -10000 I get following result:

The two 16-bit binary values for −10000 converted to decimal are:

  1. First 16-bit word (1100011000011100): 50716
  2. Second 16-bit word (0100000000000000): 16384

I tried your solution, too and was kinda bound to maximum charge power of 3500W, Now it goes up to 9000W as it should in my setup.

Glad it helped :slight_smile:

3500W as maximum was in my configuration due to my setup having it’s own limitation (BYD HVM13.8 with Plenticore10) - it allowed for maximum of 3500W charge and discharge.

@indiakiloecho

may you can help me with the value on a PC 5.5 and a BYD HVS 10.2?

I asked ChatGPT and get this values:

10%
50420 and 0
100%
50744 and 32768

Can this be right?

Thank you for your short answer.

BR

Can you explain me this part? My Riemann sum integral sensor helper for IN energy works fine and gives me the correct data.
But with the last one, I get strange values.

Is it possible, that this depends on what kind of Endian you have configured ? In my case the Big Endian Sunspec configuration is definitely not working properly…