Small utility to read data from SOFAR K-TLX inverters through the Solarman (LSW-3/LSE) datalogger. Two scripts to get inverter's statistics and hardware info. Tested with logger S/N 17xxxxxxx and 21xxxxxxx (protocol V5). Requires python3 to run.
REMARK: To make it work with other inverter brand/model connected via LSW-3/LSE you might need to alter the register's addresses in the .xml files accordingly and change register start/end numbers in config.cfg
Thanks to @jlopez77 https://github.com/jlopez77 for logger/MODBUS protocol code. Thanks to @markruys https://github.com/markruys/gw2pvo for command line tool/library to upload solar data from power inverter to the PVOutput.org website..
To run, script requires following python modules:
gw2pvo
Remove the requirement / functionality for the following Python modules (simplifying the code for support Openwrt):
libscrc
paho-mqtt
influxdb
Edit the config.cfg and enter the following data:
[SofarInverter]
inverter_ip=X.X.X.X # data logger IP
inverter_port=8899 # data logger port
inverter_sn=XXXXXXXXXX # data logger S/N
register_start1=0x0000 # Inverter register's first MODBUS address for the first register's range.
register_end1=0x0027 # Inverter register's last MODBUS address for the first register's range
register_start2=0x0105 # Inverter register's first MODBUS address for a second register's range
register_end2=0x0114 # Inverter register's last MODBUS address for a second register's range
registerhw_start=0x2000 # Like above, but for InverterHWData.py
registerhw_end=0x200D # Like above, but for InverterHWData.py
lang= # Output language (available: PL,EN)
verbose=0 # Set to 1 for additional info to be presented (registers, binary packets etc.)
[Domoticz]
domoticz_support=0 # 0: disabled, 1: enabled
[PVOutput]
pvo_system_id= # The API Key
pvo_api_key= # The System Id of your device
Files SOFARMap.xml and SOFARHWMap.xml contain MODBUS inverter's registers mapping for Sofar Solar K-TLX product line
and Prometheus/InfluxDB metrics configuration.
Edit i.e. to get captions in a different language, change Prometheus/InfluxDB metrics names or
if Your inverter has different register's numbers.
Example SOFARMap.xml structure and fields definition (similar for SOFARHWMap.xml):
"directory": "solar", # Id
"items": [
{
"titleEN": "PV1 Power", # English JSON output name
"titlePL": "Moc PV1", # Polish JSON output name
"registers": ["0x000A"], # Inverter's register address (must be in range configured in the config file)
"DomoticzIdx": 0, # Domoticz virtual device idx number (for Domoticz support)
"optionRanges": [], # For numeric value to text label mappings
"ratio": 10, # Value ratio (will be used to multiply response value)
"unit": "W", # Value unit
"graph": 1, # Set to 1, to export value to Prometheus/InfluxDB
"metric_type": "gauge", # Prometheus metric type
"metric_name": "SolarPower",# Prometheus/InfluxDB container name
"label_name": "Power", # Prometheus/InfluxDB label name
"label_value": "PV1" # Prometheus/InfluxDB value name
}
bash:/python3 InverterData.py (or ./InverterData.py)
{
"Inverter status": "Normal",
"Fault 1": "No error",
"Fault 2": "No error",
"Fault 3": "No error",
"Fault 4": "No error",
"Fault 5": "No error",
"PV1 Voltage (V)": 403.7,
"PV1 Current (A)": 0.14,
"PV2 Voltage (V)": 78.9,
"PV2 Current (A)": 0.0,
"PV1 Power (W)": 50,
"PV2 Power (W)": 0,
"Output active power (W)": 20,
"Output reactive power (kVar)": -0.65,
"Grid frequency (Hz)": 49.98,
"L1 Voltage (V)": 241.8,
"L1 Current (A)": 0.93,
"L2 Voltage (V)": 240.4,
"L2 Current (A)": 0.91,
"L3 Voltage (V)": 240.4,
"L3 Current (A)": 0.93,
"Total production (kWh)": 297,
"Total generation time (h)": 249,
"Today production (kWh)": 14010.0,
"Today generation time (min)": 679,
"Inverter module temperature (ºC)": 29,
"Inverter inner termperature (ºC)": 45,
"Inverter bus voltage (V)": 655.8,
"PV1 voltage sample by slave CPU (V)": 402.6,
"PV1 current sample by slave CPU (A)": 79.1,
"Countdown time (s)": 60,
"Inverter alert message": 0,
"Input mode": 1,
"Communication Board inner message": 0,
"Insulation of PV1+ to ground": 1379,
"Insulation of PV2+ to ground": 2387,
"Insulation of PV- to ground": 1917,
"Country": "Poland",
"String 1 voltage (V)": 9.3,
"String 1 current (A)": 24.04,
"String 2 voltage (V)": 9.1,
"String 2 current (A)": 24.04,
"String 3 voltage (V)": 9.3,
"String 3 current (A)": 0.0,
"String 4 voltage (V)": 29.7,
"String 4 current (A)": 0.0,
"String 5 voltage (V)": 24.9,
"String 5 current (A)": 14.01,
"String 6 voltage (V)": 67.9,
"String 6 current (A)": 0.29,
"String 7 voltage (V)": 4.5,
"String 7 current (A)": 65.58,
"String 8 voltage (V)": 402.6,
"String 8 current (A)": 7.91
}
bash:/python3 /InverterHWData.py (or ./InverterHWData.py)
{
"Product code": "5kW",
"Serial Number": "SXXXXXXXXXXX",
"Software Version": "V270",
"Hardware Version": "V100",
"DSP Version": "V270"
}
You tell me :)
Feel free to suggest :) If You want to rewrite or/add change anything - please fork Your own project.
Steps to run PVOutput support:
Furthermore, you need a (free) PVOutput account. Register a device and enable the API. From PVOutput you need:
The API Key
The System Id of your device