Skip to content

Instantly share code, notes, and snippets.

@Floppe
Last active August 5, 2023 17:10
Show Gist options
  • Save Floppe/83365483954d8bcee8d8854eeb3fa818 to your computer and use it in GitHub Desktop.
Save Floppe/83365483954d8bcee8d8854eeb3fa818 to your computer and use it in GitHub Desktop.
Sofar Solar KTL-X G3 inverter to be used with HomeAssistant Solarman integration
# Sofar 3.3-12KTLX-G3
# Note: no modbus energy meter connected
requests:
- start: 0x0404
end: 0x042E
mb_functioncode: 0x03
- start: 0x0484
end: 0x04BC
mb_functioncode: 0x03
- start: 0x0584
end: 0x0589
mb_functioncode: 0x03
- start: 0x0684
end: 0x069B
mb_functioncode: 0x03
parameters:
- group: InverterDC
items:
- name: "PV1 Power"
class: "power"
state_class: "measurement"
uom: "W"
scale: 10
rule: 1
registers: [0x0586]
icon: 'mdi:solar-power'
- name: "PV2 Power"
class: "power"
state_class: "measurement"
uom: "W"
scale: 10
rule: 1
registers: [0x0589]
icon: 'mdi:solar-power'
- name: "PV1 Voltage"
class: "voltage"
state_class: "measurement"
uom: "V"
scale: 0.1
rule: 1
registers: [0x0584]
icon: 'mdi:alpha-v-circle-outline'
- name: "PV2 Voltage"
class: "voltage"
state_class: "measurement"
uom: "V"
scale: 0.1
rule: 1
registers: [0x0587]
icon: 'mdi:alpha-v-circle-outline'
- name: "PV1 Current"
class: "current"
state_class: "measurement"
uom: "A"
scale: 0.01
rule: 1
registers: [0x0585]
icon: 'mdi:current-dc'
- name: "PV2 Current"
class: "current"
state_class: "measurement"
uom: "A"
scale: 0.01
rule: 1
registers: [0x0588]
icon: 'mdi:current-dc'
- group: Inverter
items:
- name: "Inverter status"
class: ""
state_class: "measurement"
uom: ""
scale: 1
rule: 1
registers: [0x0404]
lookup:
- key: 0
value: "Waiting"
- key: 1
value: "Detection"
- key: 2
value: "Grid-Connected"
- key: 3
value: "Emergency Power Supply"
- key: 4
value: "Recoverable Fault"
- key: 5
value: "Permanent Fault"
- key: 6
value: "Upgrade"
- key: 7
value: "Self-charging"
icon: 'mdi:wrench'
- name: "Ambient temperature 1"
class: "temperature"
uom: "°C"
scale: 1
rule: 2
registers: [0x0418]
icon: 'mdi:thermometer'
- name: "Module temperature 1"
class: "temperature"
uom: "°C"
scale: 1
rule: 2
registers: [0x0420]
icon: 'mdi:thermometer'
- name: "Radiator temperature 1"
class: "temperature"
uom: "°C"
scale: 1
rule: 2
registers: [0x041A]
icon: 'mdi:thermometer'
- name: "Insulation Resistance"
class: "none"
uom: "kohm"
scale: 1
rule: 1
registers: [0x042B]
icon: "mdi:omega"
- group: OnGridOutput
items:
- name: "Frequency Grid"
class: "frequency"
uom: "Hz"
scale: 0.01
rule: 1
registers: [0x0484]
icon: 'mdi:sine-wave'
- name: "Total Active Power Output"
class: "energy"
uom: "kW"
scale: 0.01
rule: 1
registers: [0x0485]
icon: "mdi:solar-power"
- name: "Grid Voltage L1"
class: "voltage"
uom: "V"
scale: 0.1
rule: 1
registers: [0x048D]
icon: "mdi:alpha-v-circle-outline"
- name: "Grid Current L1"
class: "current"
uom: "A"
scale: 0.01
rule: 1
registers: [0x048E]
icon: "mdi:alpha-a-circle-outline"
- name: "Grid Voltage L2"
class: "voltage"
uom: "V"
scale: 0.1
rule: 1
registers: [0x0498]
icon: "mdi:alpha-v-circle-outline"
- name: "Grid Current L2"
class: "current"
uom: "A"
scale: 0.01
rule: 1
registers: [0x0499]
icon: "mdi:alpha-a-circle-outline"
- name: "Grid Voltage L3"
class: "voltage"
uom: "V"
scale: 0.1
rule: 1
registers: [0x04A3]
icon: "mdi:alpha-v-circle-outline"
- name: "Grid Current L3"
class: "current"
uom: "A"
scale: 0.01
rule: 1
registers: [0x04A4]
icon: "mdi:alpha-a-circle-outline"
- group: Generation
items:
- name: "PV Generation today"
class: "energy"
state_class: "total_increasing"
uom: "kWh"
scale: 0.01
rule: 3
registers: [0x0685,0x0684]
icon: 'mdi:solar-power'
- name: "PV Generation total"
class: "energy"
state_class: "total_increasing"
uom: "kWh"
scale: 0.1
rule: 3
registers: [0x0687,0x0686]
icon: 'mdi:solar-power'
- name: "Load consumption today"
class: "energy"
state_class: "total_increasing"
uom: "kWh"
scale: 0.01
rule: 3
registers: [0x0689,0x0688]
icon: 'mdi:lightning-bolt-outline'
- name: "Load consumption total"
class: "energy"
state_class: "total_increasing"
uom: "kWh"
scale: 0.1
rule: 3
registers: [0x068B,0x068A]
icon: 'mdi:solar-power'
- group: Alert
items:
- name: "Alert"
class: ""
state_class: ""
uom: ""
scale: 1
rule: 6
registers: [0x0405,0x0406,0x0407,0x0408,0x0409,0x040A,0x040B,0x040C,0x040D,0x040E,0x040F,0x0410]
- name: "Fault 1"
class: ""
state_class: ""
uom: ""
scale: 1
rule: 1
registers: [0x0405]
icon: 'mdi:wrench'
lookup:
- key: 0
value: "No error"
- key: 1
value: "ID01 Grid Over Voltage Protection"
- key: 2
value: "ID02 Grid Under Voltage Protection"
- key: 4
value: "ID03 Grid Over Frequency Protection"
- key: 8
value: "ID04 Grid Under Frequency Protection"
- key: 16
value: "ID05 Leakage current fault"
- key: 32
value: "ID06 High penetration error"
- key: 64
value: "ID07 Low penetration error"
- key: 128
value: "ID08 Islanding error"
- key: 256
value: "ID09 Grid voltage transient value overvoltage 1"
- key: 512
value: "ID10 Grid voltage transient value overvoltage 2"
- key: 1024
value: "ID11 Grid line voltage error"
- key: 2048
value: "ID12 Inverter voltage error"
- key: 4096
value: "ID13 Anti-backflow overload"
- key: 8192
value: "ID14"
- key: 16384
value: "ID15"
- key: 32768
value: "ID16"
- name: "Fault 2"
class: ""
state_class: ""
uom: ""
scale: 1
rule: 1
icon: 'mdi:wrench'
registers: [0x0406]
lookup:
- key: 0
value: "No error"
- key: 1
value: "ID17 Grid current sampling error"
- key: 2
value: "ID18 Grid current DC component sampling error (AC side)"
- key: 4
value: "ID19 Grid voltage sampling error (DC side)"
- key: 8
value: "ID20 Grid voltage sampling error (AC side)"
- key: 16
value: "ID21 Leakage current sampling error (DC side)"
- key: 32
value: "ID22 Leakage current sampling error (AC side)"
- key: 64
value: "ID23 Load voltage DC component sampling error"
- key: 128
value: "ID24 DC input current sampling error"
- key: 256
value: "ID25 DC component sampling error of grid current (DC side)"
- key: 512
value: "ID26 DC input branch current sampling error"
- key: 1024
value: "ID27"
- key: 2048
value: "ID28"
- key: 4096
value: "ID29 Leakage current consistency error"
- key: 8192
value: "ID30 Grid voltage consistency error"
- key: 16384
value: "ID31 DCI consistency error"
- key: 32768
value: "ID32"
@MatteCarra
Copy link

Thanks a ton I will check it out!

Regarding your question, I have a Sofar 6KTLM-G3 (I think it's slightly different from your model).
If you go at page 31-32 of your user manual you will find the instructions on how to connect a meter to the inverter.
At page 48 it says "Note: Meter is supplied separately to the inverter. Please contact your distributor to order a meter."

My inverter instead offered the possibility to connect the CT clamp directly to two pins of the inverter.
Furthermore the manual said the exact CT clamp model and spec to buy, so I just bought it as specified.

@Floppe
Copy link
Author

Floppe commented Dec 30, 2022

Glad I could help.
Yes, mine is 3 phase. So I guess it does not support CT clamps, but requires a smart meter.

@gushcs
Copy link

gushcs commented Apr 17, 2023

I have a 6KTLM-G3-A and using all info that you guys provided here, Ive made my own version. Hope it helps someone.
Ps. only "Alert sensor" not working

I dont know how to paste the code here, but the link is below.

https://gist.github.com/gushcs/223ca2c61af2d345238d286746617650

@coolnr
Copy link

coolnr commented Apr 29, 2023

I tried your code but somehow it isn't working. Should this work with a LSE-3 logger and Solarman integration?

@waaslandwolf
Copy link

Same here. This yaml config file does not work with my KTL-X-G3 inverter and LSW3 wifi logger (serial 23500xxxxx). Status_connection shows disconnected and most values list as unavailable. The solarman integration works with config file sofar_lsw3.yaml (but this shows incorrect values in the registers since they do not map with my inverter).

If you would have any pointers on how to troubleshoot this then they would be much appreciated!

@waaslandwolf
Copy link

I finally got it working with this file: custom_parameters.yaml.txt (with LSMW3_15_270A_1.50 and SOFAR 8.8KTLX-G3)

@sanderbaks
Copy link

I finally got it working with this file: custom_parameters.yaml.txt (with LSMW3_15_270A_1.50 and SOFAR 8.8KTLX-G3)

WORKS FOR ME AS WELL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment