Gather values from Kostal KSEM

I have not yet found any suggestions as to how values from the “Kostal Smart Energy Meter”, KSEM in Openhab can be usefully read in.
So I set out on a search and am now trying my hand at a first tutorial of my own.

This script here has served as a template. Added some modification to directly output values in JSON structure, maybe someone on interest wants to download resulting script.

Next, adjust the IP-address and port within the script. Rename, save and place it to your needs, e.g. below


Please also check to have enabled the MODBUS-TCP on KSEM webinterface.
Probably pymodbus must also be installed via pip at your environment:

sudo python -m pip install -U pymodbus

next, perform a check if you recieve answer with

python /etc/openhab2/scripts/python/

if answer is a JSON structure with valid values from KSEM you may want to proceed:

  • create some items to handle information within OH KSEM.items.txt (7.8 KB) (sry, I’m using labels in German language)
  • use some rules to gather values from KSEM and parse JSON answer automatically: ksem-read.rules.txt (13.1 KB) file to automatically receive values from KSEM.
  • if interested: add persistence group to the items in their definition file or add items to persistence definition file.

As while running on linux, the KSEM is using mosquitto already for internal purposes only right now. There is also a feature request for receiving values directly on MQTT broker. This might be a great feature, also on performance, because values would be transmitted

  • when changing directly from the KSEM
  • without additional requests from anything
  • without format conversions
  • additional information could be output, which is currently not available via MODBUS TCP

KSEM itself can act as a MODBUS client to larger number of solar converters and capture information from them. It is a very central component on its own design.
Let’s see if Kostal will show some interest in giantly improving their product :wink:

1 Like

I do not quite understand if you got any values from the KSEM. Can you upload your read code somewhere?

Can you please try to be more specific about what is not working properly for you?