Kostal Smart Energy Meter Integration

Hm i get money every month Because every kWh i cant consume i sell… Is it not the same?

Yes, i understand that you sell excess power to the grid. But KSEM does not know about it as its placed “behind” the inverter on the house side, it sits on “Home Consumption” and can see what the house is consuming.

What you want to see is what the inverter is outputting to grid, use the native integration - see the link Kostal Plenticore Solar Inverter - Home Assistant

i’m using that already :).

But at the moment i’m little bit confused what exactly is the best solution. Can you tell me your opinion and why?

Sorry for confusion, if you are using the native integration then you can see your grid power usage from inverters perspective

sensor.[invertername]_grid_power should be the one youre looking for?

hm can you help me to get this working? it’s not possible to add it to the energie dashboard :(. i think i need to change it to Wh or Kwh correct?
i can check the state of sesor.xxxx_grid_power.

but i can’t select it here:

Netzverbrauch: sensor.scb_home_consumption_from_grid_total
Zurück zum Netz: sensor.scb_energy_discharge_to_grid_total

Dont these work?

i will try thanks! I thought i need a sensor on minute base…

after updating to 2023.10 HA would not restart due to this YAML code. Seems that something has changed with modbus in YAML. Logs told me

`count: 2` cannot be combined with `data_type: uint32`

checked the documentation, found that

count integer (Optional)
Number of registers to read. only valid for data_type: custom and data_type: string, for other data types count is automatically calculated.

so I commented the “count: 2” and “count: 4” lines out, since the doc says it will be calculated automatically for uint32 and uint64. Works again :slight_smile:

1 Like

Thank you for that precision :star_struck: , just got deperate with the error above

Hi,
i already triet out nearly every combination, but still it doesn’t work.
I pastet your code in configuration.yaml, replaced the correct IP, removed the lines with “count:…” and it still doesn’t work.
My configuration is:

  • Kostal Plenticore plus 10.0
  • Kostal Plenticore plus 7.0
  • Kostal Smart Energy Meter G2
  • BYD HVS Battery, 12.8 kWh

Every component is connected to the LAN.
KSEM is installed at grid connection point.
The inverters are already connected and can be found in the devices overview.
But the sensors from ksem can’t be found in the entities.
Home Assistant is installed since 2 days, Version 2023.11.

Does anyone have an idea?

Good afternoon.

I am an active user of KOSTAL products. Thank you for your products.

At the moment, I have integrated KSEM into the HOME ASSISTANT system. But I only have a few sensors connected whose data I could find. For complete integration I need your help. Please send me, if possible, the names of all the sensors that ksem has (especially interested in voltage sensors and solars sensors) and the addresses of these sensors in the KSEM system.
Thank for advance

Hello. Some One can help? I need add to Home Assistant for KSEM next positions. (please see attached file). But like sensors it’s not working!

Please , Help add next information to Home assistant

Hi,
I’m using a KSEM G2 and to add it to HA I have proceeded as following:

The communication protocol used between HA & KSEM is the “modbus”.
In the configuration.yaml, I have added the following line to tell HA how to communicate with the KSEM and where to find the registers definition. This is called the modbus integration
This is the syntax used. The include file is used to make the configuration.yaml more readable.

modbus: !include modbus.kostal.yaml

Content of this modbus.kostal.yaml:

- name: "KSEM" #can be anything you want
  type: tcp    #modbus over tcp 
  host: 192.168.xxx.xxx  #insert your KSEM ip address, eg "host: 192.168.1.100"
  port: 502              #insert your KSEM port, eg "port: 502"
  sensors: !include_dir_merge_list modbus/kostal/ksem/

To avoid a long list of register descriptions in one single file I splitted those registers in 3 categories according to the type of registers described in the KSEM interface guide. Each register category is in a separated YAML file:

  • ksem_reg_internal_Energy.yaml
  • ksem_reg_internal_instantaneous.yaml
  • ksem_reg_Sunspec.yaml

All 3 YAML files have been saved under /homeassistant/modbus/kostal/ksem.
In the modbus.kostal.yaml the last line:

sensors: !include_dir_merge_list modbus/kostal/ksem/

Tell to HA to read any yaml file located under the subfolder modbus/kostal/ksem/

Syntax example used in the ksem_reg_internal_Energy.yaml:

  • Active Energy from Grid
  • Active Energy to Grid
- name: "KSEM Total Active Energy from Grid" # Active energy+
  unique_id: kostal_ksem_total_active_energy_from_grid
  address: 512
  slave: 1
  device_class: energy
  state_class: total_increasing
  unit_of_measurement: kWh
  input_type: holding
  data_type: uint64
  precision: 2
  scale: 0.0001
  scan_interval: 60
- name: "KSEM Total Active Energy to Grid" # Active energy-
  unique_id: kostal_ksem_total_active_energy_to_grid
  address: 516
  slave: 1
  device_class: energy
  state_class: total_increasing
  unit_of_measurement: kWh
  input_type: holding
  data_type: int64
  precision: 2
  scale: 0.0001
  scan_interval: 60

In HA, after a reboot, the registers appears under “entities”.
For example, both Active Energy from/to Grid shown above can be used in HA Energy dashboard to display the Energy statistics.

Of course everything can be simplified if only few registers are needed, keeping all in the configuration.yaml or in one single include file.

Hope it helps.

2 Likes

Thank You for answer.
KSEM working in my HA(You can see in picture) , but I need help for syntax for next parameter - Home Consumption and Sum Output inverter AC.
I try to use syntax like for sensors but it not working ;(

OK. I didn’t use these specific registers because I collect the inverter information directly from the inverter. My inverter is a Kostal PIKO C 50 and to collect the data from, I have installed the SunSpec integration available under the HACS.
These specific KSEM registers are supposed to be read at address starting 40960 + the offset for each register. I will give it a try …

Thank You.
Befor I try did like

  • name: ‘Home Consumption’
    unit_of_measurement: “kWh”
    slave: 1
    address: 22
    data_type: int32
    scale: 0.01
    precision: 1
    scan_interval: 20
    device_class: energy
    state_class: total_increasing

but not working !

I have added 2 registers in my YAML and it seems to work.

- name: "KSEM Sum output inverter AC"
  unique_id: kostal_ksem_inverter_sum_power_AC
  address: 40974
  slave: 1
  device_class: power
  state_class: measurement
  unit_of_measurement: kW
  scale: 0.001
  scan_interval: 60
  input_type: holding
  precision: 2
  data_type: int32
  
- name: "KSEM Sum PV power inverter DC"
  unique_id: kostal_ksem_sum_inverter_pv_power_DC
  address: 40976
  slave: 1
  device_class: power
  state_class: measurement
  unit_of_measurement: kW
  scale: 0.001
  scan_interval: 60
  input_type: holding
  precision: 2
  data_type: uint32

For the home consumption, the address is 40982 (40960 + 22).

Edit: Parameters to read as an instantaneous power value

 device_class: power
 state_class: measurement
 unit_of_measurement: kW

Parameters to read as statistic (cumulated), energy in kWh

 device_class: energy
 state_class: total_increasing
 unit_of_measurement: kWh

Because the KSEM register give a value in W, I have made the scale here in the YAML to have already a value (divided by 1000) in kW or kWh:

 scale: 0.001

Hope this helps

1 Like

Fantastic!
Thank You!
Working!

Hi, these are the information I was also looking for.
Thx for that.
BUT I am facing the problem that I am not able to get the home consumption working also I tried the ones mentioned above. No success. State is always unavailable. Others work as a charm.

Setup: 2x Kostal Plenticore Plus (Master/Slave) KSEM G2 and BYD Battery
HA: 2024.3.1 OS: 12.1

    - name: "KSEM Home Consumption"
      unique_id: kostal_ksem_home_consumption
      address: 40982
      slave: 1
      device_class: power
      state_class: measurement
      unit_of_measurement: kW
      scale: 0.001
      scan_interval: 60
      input_type: holding
      precision: 2
      data_type: int32

I hope somebody can help me. Thx for reading.
KR Supergrobi