baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

KOSTAL PIKO + KSEM G2 modbus API access etc.

KOSTAL KSEM G2 (modbus TCP) grid power total:
1) In device configuration, enable ModBus TCP slave
2) Install mbpoll
3) Read power meter using command line:

mbpoll -t 3:int16 -r 2,4 192.168.1.12

Simple bash parsing example:

mbpoll -r 2,4 192.168.1.12 -1 -q > /tmp/mbpoll.txt
grid=$(grep "\[2\].*" -m 1 /tmp/mbpoll.txt | cut -d ':' -f 2 | tr -d '\t ' | cut -d '(' -f 1 )
feedback=$(grep "\[4\].*" -m 1 /tmp/mbpoll.txt | cut -d ':' -f 2 | tr -d '\t ' | cut -d '(' -f 1 )
pwr=$(( (grid - feedback)/10 ))
echo "$pwr W"

KOSTAL PIKO solar output (bash/wget):
1) Using bash you can easily read the current SOLAR output in WATT:

#!/bin/bash
pvwatt=$(wget -qO - "http://192.168.1.11/api/dxs.json?dxsEntries=67109120" | cut -d ','
-f 2 | cut -d ':' -f 2 | cut -d '}' -f 1 | cut -d '.' -f 1)
echo "$pvwatt W"

Comments are currently closed.