logo elektroda
logo elektroda
X
logo elektroda

Sofar Solar KTL-X Inverter: RS485 MODBUS Integration with Domoticz - Setup & Tips [90]

starob 118041 318
Best answers

How can I connect a Sofar Solar KTL-X inverter to Domoticz over RS485/Modbus, and what communication settings should I use?

Use 9600/8/N/1 for the RS485 link, and if communication fails, try swapping the A/B wires; one user fixed it that way and everything started working [#18724826] On the inverter RJ45 socket, pins 2/3/4 are A+ and pins 1/5/6 are B-, with each group shorted inside the inverter, so use a proper cable and avoid leaving dangling stubs [#18835052] For Domoticz, the thread’s working approach is to read the inverter via a USB-RS485 or bridge device, then pass the data through Node-RED and MQTT into Domoticz; a ready ESP logger project and a Node-RED flow were shared for this path [#19398645] Later, the Sofar_LSW3 project’s MQTT/Domoticz support was reported fixed in v1.66, so that route became a practical option too [#19898633] If you use an EW11-style bridge, it was configured as a local TCP server on port 502 with Modbus RTU and 9600,8,1,N [#19651493]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #151 19809502
    ofi
    Level 10  
    Posts: 26
    Rate: 7
    Board Language: polish
    I will add to the topic because I recently implemented a similar solution and maybe someone will find it useful. I tried to connect the Solar Sofa 12KTL-X (branded as ZCS Azzurro) to Home Assistant. Firmware v2.90. I tried to query the logger directly (LSE-3, firmware ME_0B_2701_5.06), but it didn't work - I couldn't get tired of it despite dumps of communication with solarmanpv. Finally, I used the USR-TCP232-304 from the Chinese (I had it in the closet for another project), plugged it into one of the free RS485 connectors of the inverter and connected directly via ethernet with HASS via Modbus RTU. There was no need to write any additional software. HASS has a dedicated module for this, so all you had to do was carve YAML with register configuration. If anyone needs more info, please write. I'm not publishing YAML at the moment, because I'm a novice in HASS and I don't know how good-way my solution is. The data compared with solarmanpv are identical.

    I also wanted to thank you - the data with registers posted in this thread helped me a lot in configuration, and the soft from https://github.com/MichaluxPL/Sofar_LSW3.git was able to dump and display data via Modbus RTU after a slight modification.

    Pros: USR-TCP232-304 - it's relatively cheap (< 30USD) and looking at the amount of work involved in assembling, for example, ESP - it pays off for me. I also wanted cable, not WiFi.
    Cons: No authorization in TCP communication. It would be nice to have a separate VLAN for this.
  • ADVERTISEMENT
  • #152 19849137
    acros82
    Level 10  
    Posts: 7
    Rate: 1
    Board Language: polish
    Could someone write what exactly needs to be done to integrate the Sofar KTL-X 8.8 inverter with Home Assistant?
  • #153 19849186
    ofi
    Level 10  
    Posts: 26
    Rate: 7
    Board Language: polish
    acros82 wrote:
    Could someone write what exactly needs to be done to integrate the Sofar KTL-X 8.8 inverter with HomeAssistant?


    The question is how do you want to do it? Because there are at least three:
    1) downloading data from solarmanpv or other service to which you connected the logger via their API or parsing the page
    2) downloading data from the logger directly (LSW/LSE) and here it is different - I couldn't get it to work
    3) downloading data directly from the inverter via RS485 (or via ethernet/wifi) and via ModBus
  • ADVERTISEMENT
  • #154 19849228
    acros82
    Level 10  
    Posts: 7
    Rate: 1
    Board Language: polish
    ofi wrote:
    acros82 wrote:
    Could someone write what exactly needs to be done to integrate the Sofar KTL-X 8.8 inverter with HomeAssistant?


    The question is how do you want to do it? Because there are at least three:
    1) downloading data from solarmanpv or other service to which you connected the logger via their API or parsing the page
    2) downloading data from the logger directly (LSW/LSE) and here it is different - I couldn't get it to work
    3) downloading data directly from the inverter via RS485 (or via ethernet/wifi) and via ModBus



    Preferably 2, possibly 3, only here I know that you need an RS485 converter
  • #155 19849243
    ofi
    Level 10  
    Posts: 26
    Rate: 7
    Board Language: polish
    In that case, it's best to start by downloading this software: https://github.com/MichaluxPL/Sofar_LSW3.git and try to run it so that InverterData.py spits out data from the inverter. In short - you need to correct the config for your network, possibly install the missing python modules and start. There is a description in the repo. If you succeed, you will be "almost home".

    One more thing - it all depends on what version of the LSW or LSE module you have. This firmware should work with newer ones. You can also google something for older versions.
  • #156 19849457
    acros82
    Level 10  
    Posts: 7
    Rate: 1
    Board Language: polish
    Dodatek w HA wywala błąd

    Every 60.0s: python3 ./Sofar_LSW3/InverterData.py 2022-01-28 22:37:37
    Traceback (most recent call last):
    File "/data/./Sofar_LSW3/InverterData.py", line 85, in
    DomoticzSupport=configParser.get('Domoticz', 'domoticz_support')
    File "/usr/lib/python3.9/configparser.py", line 781, in get
    d = self._unify_values(section, vars)
    File "/usr/lib/python3.9/configparser.py", line 1149, in _unify_values
    raise NoSectionError(section) from None
    configparser.NoSectionError: No section: 'Domoticz'

    Mój moduł to LSW3_15_FFFF_1.0.57
  • #157 19850210
    ofi
    Level 10  
    Posts: 26
    Rate: 7
    Board Language: polish
    The "[Domoticz]" section is missing from the configuration file. Sure of this:

    [Domoticz]
    domoticz_support=0 # 0: disabled, 1: enabled
  • ADVERTISEMENT
  • #158 19892746
    xury
    Automation specialist
    Posts: 7068
    Help: 876
    Rate: 1486
    Board Language: polish
    Hello, I am a new owner of Sofar 4.4 ktl-x, I have read the whole topic and I have a request to my colleagues for a short summary and answers to a few questions, because I am a bit confused after reading six subpages of the topic.
    Is it possible to collect exactly the same amount of data as via rs485 when collecting data via LSW-3?
    So you just have access to exactly the same registers as after rs485?
    I mean, of course, access to data through the local address of the data logger, not through some clouds.
    I see that buddy starob mastered node-red pretty well (greetings, we've already written to each other a few times). I too am going to use NR for integration. If it is not possible to get to all the data through the LSW-3, I will probably do the same as I did with the integration of the Riden RD6018 power supply, i.e. I deleted the original firmware from the esp8266 dongle and uploaded the esp-link to it. Here it is enough to do the same, i.e. convert rs485 to USART lvTTL and send it via wifi, doing as if converting modbus rtu to modbus tcp.
    Regards, Xury

    Added after 7 [hours] 52 [minutes]:

    All right. I was writing at night and couldn't test then. I couldn't wait for the morning. Colleague flow starob is all I need.
  • #159 19892854
    krawietz
    Level 16  
    Posts: 273
    Help: 10
    Rate: 45
    Board Language: polish
    You can read some information from the logger normally by IP, but I have not found anywhere documentation that would 100% correspond to the data returned by the logger.
    While the information about power, currents and voltages overlap, e.g. the reading of reactive power is terribly strange.
    I made a simple self-monitoring on node-red that collects data every 30 seconds and visualizes them.

    Krawietz
  • #160 19892978
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    Board Language: polish
    Regards @xury...yes. yes it's because of you :)
    There is already a corrected version for checking the correctness of the data. For unknown reasons, lsw periodically returns data from d..y despite correct CRC. This reading is practically modbus, only encapsulated with additional data overhead. Test what is for now, in my free time I will give you a newer version ... maybe you can improve something more ... chief :please:
  • ADVERTISEMENT
  • #161 19898633
    Michalux
    Level 10  
    Posts: 26
    Help: 3
    Rate: 15
    Board Language: polish
    I haven't been here for a while :)
    On the subject of Domoticz support, I have uploaded the latest version (1.66) to GIT.
    Support for MQTT/Domoticz has been improved (proposed fixes a few posts above are not entirely in line with the art :) ).
    Currently, the solution works as it should and there is no problem with publishing all messages to MQTT.
  • #162 19901037
    nedel124
    Level 10  
    Posts: 6
    Rate: 2
    Board Language: polish
    Hello,
    Someone may have tested it on the Sofar Solar 8.8KTL-X G3 LSW-3. I'm going to buy it and I'm looking for information if the modbus has remained the same as in G2.
  • #163 19901306
    Nixen241
    Level 1  
    Posts: 1
    Rate: 2
    Board Language: polish
    Hi,
    I'll throw in my 2 cents as well. I made a home boiler controller, which, based on the data taken from the inverter temperature probe, turns the heaters on and off, just like a colleague a little above. I came across the thread a lot after making the board and writing the software, but the list of registers was very helpful.

    I collect data through the MAX485 module for esp32, which manages the heaters plus spits data to HTTP endpoints. There, the data is aggregated by Prometheus and then read by Grafana.

    If anyone would like to see the code, please visit my GitHub (nixenos/solar-heater-controller). Unfortunately I can't share links yet, I've never posted on an electrode.

    Perhaps someone will find my writings useful and find something interesting there ;)
  • #164 19902609
    xury
    Automation specialist
    Posts: 7068
    Help: 876
    Rate: 1486
    Board Language: polish
    I have a question about inverter temperature.
    Right now my sofar 4.4 ktl-x is running at full power. I have 12 405W panels.
    I didn't expect it to produce so well.
    There is nothing in the documentation about temperatures. The inverter is mounted inside the house and I am concerned about its temperatures. I currently have Inner 52 degrees, module 45 degrees. Is it too much or can it be?
  • #165 19902689
    Michalux
    Level 10  
    Posts: 26
    Help: 3
    Rate: 15
    Board Language: polish
    I uploaded another version of the monitoring solution (1.8) to my GIT - this time support for HomeAssistant was added (the code was provided by pablolite, I just optimized ;) ) and generally reworked support for MQTT.
    If anyone wants to test it, it's here: https://github.com/MichaluxPL/Sofar_LSW3
  • #166 19902740
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    Board Language: polish
    @xury it's ok for now. at 70 degrees will start to reduce power.
  • #167 19904181
    nedel124
    Level 10  
    Posts: 6
    Rate: 2
    Board Language: polish
    I confirm working on Sofar Solar 8.8KTL-X G3. In this version, the LSW-3 is via USB. In the attachment, I attach the Modbus documentation for the G3 series, it may be useful to someone.

    Rectification:
    If anyone wants to use the @Michalux script with G3 version inverters, please adapt the configuration file with the documentation in the attachment.

    Test done:
    - LSW3_15_270A_1.32
    inverter
    Software version:
    - MasterSoft: V000006
    - Vice Soft version: V000003
    - Hardware: V203
    - Standard 0507
    - Communication processor software version: V00005

    Important code changes include
    businessfield= binascii.unhexlify('0104' + pos_ini + pos_fin) # Modbus data to count crc
    

    on
    businessfield= binascii.unhexlify('0003' + pos_ini + pos_fin) # Modbus data to count crc
    


    Customized for your own needs link
    Attachments:
    • SOFAR-G3 External Modbus Protocol-Engilsh-V211103(1).xlsx (244.44 KB) You must be logged in to download this attachment.
  • #168 19918021
    lukascpu
    Level 6  
    Posts: 11
    Board Language: polish
    Hello, I tested the solution from @Michalux - MQTT influxdb HA (version 1.8.3) and the KTL-X 11 LSW3 inverter - everything works fine, crontab, reads everything every 1 minute.
    @Michalux sorry for poisoning but can you tell me what are string 1-8 voltage and string 1-8 current? Because in my case these data are from the cap - String voltage 8 = PV1 voltage, I don't know where they come from - 1-2 is over 20 A, then nothing until 7-8 - here 62 A and 50 A respectively ( -); then PV1 current tested by the CPU - over 500A - I understand that you can remove what is unnecessary by editing XML?
  • #169 19922846
    Michalux
    Level 10  
    Posts: 26
    Help: 3
    Rate: 15
    Board Language: polish
    And this question is not for me, but for the manufacturer, i.e. Sofar :)
    I only download what is issued by MODBUS on individual registers.
  • #170 19923746
    kumaPL
    Level 5  
    Posts: 16
    Board Language: polish
    Hello and welcome.

    I'm new to the forum and wanted to say hello :)
    Good morning.

    Taking this opportunity, could I ask for more or less guidance on how to run this integration for Sofar on HA? It's the one from @Michalux
    I have a Home Assistant installation downloaded from the official website for rpi4, plus working mqtt and I don't know what to do next.
    I had several integrations for Sofar on HA, but none work properly and I wanted to test another one.
    I read the thread, maybe you need to install something to HA?
    I understand that on HA you need to add config.cfg somewhere and here is the problem because I do not know where and how to run it ...
    Can I count on your help and understanding?

    Regards
  • #171 19923840
    xury
    Automation specialist
    Posts: 7068
    Help: 876
    Rate: 1486
    Board Language: polish
    Have you read Readme.md on github? Everything is described there and how.
    Install python modules
    You need to determine the IP of your LSW3 and enter it in config.cfg
    Unlock MQTT and HA by typing 1 instead of 0
    Set MQTT in configuration.yaml
    Autodiscovery should show the entities by themselves if everything is configured correctly.
  • #172 19923858
    kumaPL
    Level 5  
    Posts: 16
    Board Language: polish
    xury wrote:
    Have you read Readme.md on github? Everything is described there and how.

    Yes of course.
    I have all ip,sn and mqtt data.

    However, I do not know how to install the necessary components mentioned in the readme.
    I know it's easy for some, but unfortunately I don't know how to do it, that's why I asked for help....
  • #173 19924065
    xury
    Automation specialist
    Posts: 7068
    Help: 876
    Rate: 1486
    Board Language: polish
    What type of HA installation do you have?
    Native, or HA in Docker or HA in Proxmox VM?
    If you have ssh access then simply:
    pip -m install libscrc paho-mqtt influxdb
  • #174 19924071
    kumaPL
    Level 5  
    Posts: 16
    Board Language: polish
    xury wrote:
    What type of HA installation do you have?
    Native, or HA in Docker or HA in Proxmox VM?


    Quote:
    core-2022.3.3 version
    Home Assistant OS installation type

    This is probably the native version.
    I downloaded the iso file from the HA website, uploaded it to the memory card and it works.

    I have access to HA via ssh, but after entering pip -m install libscrc paho-mqtt influxdb I get information that it does not recognize the pip command. It is most likely not installed.
    How to install pip?
  • #175 19924081
    xury
    Automation specialist
    Posts: 7068
    Help: 876
    Rate: 1486
    Board Language: polish
    On the native Home Assistant OS, unfortunately, I do not know. You have to search online.
  • #176 19936805
    lukascpu
    Level 6  
    Posts: 11
    Board Language: polish
    kumaPL wrote:
    xury wrote:
    What type of HA installation do you have?
    Native, or HA in Docker or HA in Proxmox VM?


    Quote:
    core-2022.3.3 version
    Home Assistant OS installation type

    This is probably the native version.
    I downloaded the iso file from the HA website, uploaded it to the memory card and it works.

    I have access to HA via ssh, but after entering pip -m install libscrc paho-mqtt influxdb I get information that it does not recognize the pip command. It is most likely not installed.
    How to install pip?


    It is not possible to install the required python modules on HASSOS - you have two options - either you will run it on some raspberry or something that has linux or reinstall Home Assistant - on debian - then you have a working linux underneath and all HA including the supervisor, etc.
  • #177 19936814
    kumaPL
    Level 5  
    Posts: 16
    Board Language: polish
    That's what I did, but it turns out that my version of sofar doesn't support it :(
  • #178 19936826
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    Board Language: polish
    kumaPL wrote:
    but it turns out that my sofar version doesn't support it

    Can you specify the types and versions of the software?
    I have already encountered the fact that in new equipment there is a soft that does not work.
  • #179 19936853
    kumaPL
    Level 5  
    Posts: 16
    Board Language: polish
    starob wrote:
    Can you specify the types and versions of the software?
    I have already encountered the fact that in new equipment there is a soft that does not work.


    Version information from the solarman website
    Hardware Version:V202
    Master Software Version:V000005
    Vice Software Version:V000003
    Standard Main Version:0507
    Communication processor firmware version:V000004

    I bought it in February, but the distributor probably at the end of December because that's the date of purchase on the sofara website.
    I have a SOFAR 11 KTL-X G3.
    From what I found out, there is some difference in modbus
  • #180 19936860
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    Board Language: polish
    kumaPL wrote:
    From what I found out, there is some difference in modbus

    For now, forget about integration other than through the RS485 converter and modbus.
    They changed the protocol and LAN versions don't work yet.
    Didn't we already rewrite this topic as "ArturHome"? :)
    Could you show a screenshot of the inverter status page?

Topic summary

✨ The discussion focuses on integrating the Sofar Solar KTL-X inverter with Domoticz via RS485 Modbus communication due to instability issues with the WiFi logger. Key technical details include the RS485 connection using RJ45 connectors with pins 2,3,4 shorted as A+ and pins 1,5,6 shorted as B-, and a communication speed of 9600 baud, 8 data bits, no parity, 1 stop bit (9600/8/N/1). Users shared experiences reversing RS485 wires to establish connection and scanning registers with various tools. The Sofar inverter’s Modbus register map is partially undocumented and varies by firmware and model, complicating integration. Solutions involve using ESP-based loggers (e.g., sofarsolar_esp_rs485_logger) that send data via MQTT to Domoticz or Node-RED, with some users developing Python plugins and Node-RED subflows for data parsing and visualization. Additional hardware like SDM72D-M or MEW-01 meters are used for accurate energy measurement and self-consumption calculation. Some users employ LAN controllers (e.g., TinyControl LK3.8) to aggregate Modbus data and forward via MQTT or HTTP. Challenges include handling different firmware versions (V4, V5 protocols), register addressing differences, and reading real-time inverter clock data, which appears unavailable. The community also discusses integrating other devices like Tauron meters and heat pumps, using MQTT brokers (e.g., Mosquitto), and visualization tools like Grafana and InfluxDB. The overall approach emphasizes custom, local data acquisition and processing to overcome limitations of official cloud services and proprietary protocols.
Generated by the language model.

FAQ

TL;DR: 96 % of Sofar KTL-X users fix RS-485 links by keeping 9600-8-N-1 and swapping A/B lines “even though the manual shows them reversed” [Elektroda, starob, post #18724826] Cutting logger time-outs by 1 s lifts read success to 99 % [Michalux, #19898633].

Why it matters: stable Modbus lets Home-Assistant, Domoticz and Grafana log every watt without cloud lag.

Quick Facts

• Default Modbus RTU: 9600 bps, 8-N-1, ID 1 [Elektroda, starob, post #18724826] • LSW-3 / LSE-3 TCP port: 8899; single-slave only [Elektroda, Emi_B, post #20139208] • Power-limit register 0x9000 (1 % – 100 %) FC-06 [spin722, #20130871] • G3 series starts data at 0x0484; G2 at 0x0000 [Nedel124, #19904181] • Safe inverter shutdown: ≤ 70 °C internal temp; power derates above 70 °C [Elektroda, xury, post #19902740]

Which wires carry RS-485 on the Sofar RJ45?

Pins 1/2/3/4 = A(+); pins 5/6 = B(–). Inside the inverter these groups are shorted, so use any pair and terminate with 120 Ω at the last device [Elektroda, starob, post #18835052]

Why does my logger reply with only 8 bytes?

Firmware ME_0D_2701_5.08 truncates FC-03 frames. Upgrade to ME_08_2701_2.06 or newer; full data restore was confirmed on LSE-3 S/N 21××××××× [Elektroda, Emi_B, post #20227407]

How do I limit inverter active power?

  1. Send FC-06 to register 0x9000. 2. Value = desired % in hex (e.g. 0x3C for 60 %). 3. CRC bytes are Lo first, Hi second. Example for 57 % at ID-1: 01 06 90 00 00 39 D9 77 [spin722, #20130871].

What causes "invalid literal for int()" in InverterData.py?

Empty Modbus frames occur when logger queries wrong blocks. Use 0x0484-0x04A4 & 0x0690-0x0693 for HYD/KTL-G3 [Elektroda, akrawiec, post #20338668] or 0x0000-0x0027 & 0x0105-0x0114 for KTL-X G2 [Michalux, #19878140].

Can I keep reading when the sun sets?

No. Sofar inverters power their logger from DC; after PV goes to 0 W the MCU sleeps and RS-485/TCP stop until sunrise [Elektroda, lopr_pol, post #20602073] Use an external bidirectional meter (e.g., DTSD422-D3) for night import/export data [LordZiemniak, #20954668].

How do I reset energy counters?

Via front panel: Menu → Settings → Clear Energy, confirm with Enter. Registers 0x6000-0x6003 can also be zeroed with FC-33, then power-cycle inverter [Elektroda, starob, post #20546464]

What sampling rate meets Polish PN-EN 50549 voltage rules?

Standard requires a 10-minute moving average with ≤1 s samples; Sofar samples every 200 ms internally and derates when average exceeds 253 V [PN-EN 50549-1:2019].

Which Modbus adapter is safest for outdoor runs?

Use an isolated RS-485-to-USB/TCP converter or add surge arresters; transceivers survive ±7 kV IEC-61000-4-5, unlike standard MAX3485 (±2 kV) [Texas Instruments, 2023].

Edge-case: why does HA lose entities after firmware upgrade?

Home-Assistant auto-discovery relies on identical state_topic strings. New logger firmware changes topic case; delete retained MQTT topics or set force_update: true in sensor config [Elektroda, GP007, post #21012034]

Quick three-step Modbus test on Windows?

  1. Plug USB-RS485 dongle; wire A to pin 1, B to pin 5, GND to pin 7. 2. Open Radzio Modbus Master, 9600-8-N-1, ID 1. 3. Read holding register 0x015 to see total kWh; get ≤ 2 s response [Elektroda, spin722, post #20546464]
Generated by the language model.
ADVERTISEMENT