SofarSolar inverter integration

Hello, sorry but 'im nobes
Can you pleas explain this :blush:

  • Add three new variables to HA by IDE with these names:

Thanks

Hi Pawel,

Is it possible to provide the integration (hassio-addons/sofarsolar at master ¡ pawelka/hassio-addons ¡ GitHub) in the form of a custom component?

1 Like

Hi all,
did someone try to get the values out of the status page via scrape?

I think this could be the easiest way, i am just a bit confused about the syntax and the parsing of scrape :wink:
This way an integration would just be a once configuration of scrape in the configurations.yaml …
Anyone out there who alrady did this?

HI all,

With a little help I figured out how to scape the (for me) relevant values:

in the configuration.yaml:

sensor: 
  - platform: scrape
    resource: http://192.168.1.120/status.html
    name: wechselrichter_total
    authentication: basic
    username: admin
    password: admin
    select: "script"
    index: 1
    value_template: "{{ (( value.split(';')[7] ) | replace ('var webdata_total_e = ','') |replace('\"', '')|float  ) }}"
    scan_interval: 600
    unit_of_measurement: "kWh"
    
  - platform: scrape
    resource: http://192.168.1.120/status.html
    name: wechselrichter_aktuell
    authentication: basic
    username: admin
    password: admin
    select: "script"
    index: 1
    value_template: "{{ (( value.split(';')[5] ) | replace ('var webdata_now_p =','' ) |replace('\"', '') |float) }}"
    scan_interval: 30
    unit_of_measurement: "W"
    
  - platform: scrape
    resource: http://192.168.1.120/status.html
    name: wechselrichter_today
    authentication: basic
    username: admin
    password: admin
    select: "script"
    index: 1
    value_template: "{{ (( value.split(';')[6] ) | replace ('var webdata_today_e = ','')|replace('\"', '')|float )}}"
    scan_interval: 300
    unit_of_measurement: "kWh"
3 Likes

great job. it works for me.

I’d like to do the same on https://home.solarman.cn/ page… it’s full of other plant information to scrape.

1 Like

Hello to all.
I built the circuit found on github
I was able to successfully flash esp-07.bin file on ESP07 with NodeMCU Flasher.
After the flash I unplug the card, move the selector from “program” to “uart”, and restart it. But I can’t find any access points to connect to.
What did I do wrong?
Thanks.

Hi @Cholera - thanks for the info. I’m having trouble scraping any data, and I don’t really know what I’m doing(!). I used your example (but replaced the IP and removed ‘/status’ from the URL as with my firmware, the info is on the home screen). It doesn’t pull data as is for me, so I assume mine is a little different. I got myself as far as finding the inspect string for ‘Current power’ (as an example):

<div class="lab_r2" id="webdata_now_p" style="color:#666666;font-weight:bold;">570 W</div>

But not really sure what the value_template line should look like in my case. Can you, or anyone else point me in the right direction?

Cheers :grinning:

If you have or want to build custom rs485 logger based on modbus integration with inverter, please check this repo GitHub - pawelka/sofarsolar_esp_rs485_logger

I added there integration by using ESPHome or Tasmota or custom firmware (initial one). I suggest to use ESPHome integration, because it’s seamless.

Hi Pawel, i try to integrate a Sofar KTL x 8.8 with your esp rs485 logger based on the esphome code with a Wemos D1 mini (TX GPIO1, RX GPIO3) , but i have some probs with the modbus communication from the sofar inverter. The esp log says no response from modbus… The sofar shows a connected RS485 interface on their display, the RX / TX Leds on the RS 485 interface (to the wemos) flashing every update interval (10s)… The sofar has modbus id 01 the esp config pointig also th the modbus adress 0x01. Do you have any idea where else I can look? Are there any special features with the Wemos D1?

Thank you !
Rob

Try to enable debug logging in ESPhome, maybe there will be useful info what’s the problem.

Hello Pawel,
I can’t really interpret the problem in the logs, i have started with very_verbose wit this output:
[14:11:45][VV][uart.arduino_esp8266:180]: Flushing…
[14:11:45][V][modbus:184]: Modbus write: 01.04.00.00.00.01.31.CA (8)
[14:11:45][D][modbus_controller:029]: Modbus command to device=1 register=0x00 countdown=0 no response received - removed from send queue
Next i enabled the debug and uart debug (direction: BOTH), it looks like nothing is received from the sofarsolar…but why, the receive led is flashing…
[15:06:55][D][uart_debug:158]: >>> “\x01\x03\x00\x00\x00\x1E\xC5\xC2”
[15:06:55][D][uart_debug:158]: >>> “\x01\x03\x00\x00\x00\x1E\xC5\xC2”
[15:06:55][D][uart_debug:158]: >>> “\x01\x03\x00\x00\x00\x1E\xC5\xC2”
[15:06:56][D][uart_debug:158]: >>> “\x01\x03\x00\x00\x00\x1E\xC5\xC2”
[15:06:56][D][uart_debug:158]: >>> “\x01\x03\x00\x00\x00\x1E\xC5\xC2”
[15:06:56][D][modbus_controller:029]: Modbus command to device=1 register=0x00 countdown=0 no response received - removed from send queue

Do you have an idea or recommendation ?
Thanks again !
Rob

Check RX cable or change RX pin/configuration. In logs you see only transfer. Diodes on converter shows RX, but nothing in logs, it looks weird.

checked, kabels are note crossed. I connected a led on the rx line at the wemos it´s flashing simultaneously with the rx on the rs485 interface…i also crossed the tx and rx at the wemos to see if it receiving theit output and yes the debug shows reciving data and the modbus component reports a crc cheksum error…
I would now assume that the rx level from the rs485 interface does not match…

Which RS 485 interface did you use? in the pictures i can see that you connected it to 5 volts right? are the levels (3.3 volts) correct for the esp ?

Yes, I have converter connected to 5v, because this is a voltage provided by inverter. I don’t remember what’s the voltage according spec of module, but I remember that on RX and TX 3v3 signal level is supported and esp8266 operates on this level.

Hey @pawelka, congrats on the really great job! I’m using the ESPHome logger with D1 mini.
I now plan to use it to automate charging my EV from surplus energy.
One question: The enclosure in my inverter is metal, how did you insulate your module?
Also a suggestion: the logger sends huge amounts of data, for us using an SD card it is a little frightening. I guess you also wonder:

[TODO?] all registers or only useful one?

I suggest:

  1. Increase update from 10 to 60 seconds perhaps?
  2. For most of sensors (except power) you can add the following, this way people who need it will just enable it in HA:
disabled_by_default: true

BTW I think we’re from the same country. Thanks again for your contribution!

HI! Great add-on. I do get the following error:
2022-05-21 13:30:44 ERROR (MainThread) [homeassistant.components.hassio] Failed to to call /addons/3a87ddeb_sofarsolar_mqtt/stats - Container addon_3a87ddeb_sofarsolar_mqtt is not running

In MQTT viewer i don’t see the plugin.

What do I wrong?

When I start SofarSolarMQTT receive this error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/inverter/__main__.py", line 1, in <module>
    import Inverter
  File "/inverter/Inverter.py", line 10, in <module>
    import anyconfig
  File "/usr/local/lib/python2.7/site-packages/anyconfig/__init__.py", line 24, in <module>
    from .api import (
  File "/usr/local/lib/python2.7/site-packages/anyconfig/api/__init__.py", line 124
    def version() -> typing.List[str]:
                  ^
SyntaxError: invalid syntax

How can I resolve?

I have this same problem.

Trying to run rs485 logger on my Sofar Solar 8.8 KTLX-G3 but looks like G3 series has a different registers. How to fix that? Here you can find registers received from Sofar support: docs.google.com/spreadsheets/d/1p6p7n8-V2jlFid3FPPk5L4Sn4-tOWscQwpkahq5jRbs/edit#gid=157762751

Currently I can see just “0” value for every entity

And this is the output from the logs. So looks like modbus communication is established correctly

For example:
“Total Energy” in pawelka’s project has address 0x0015
image

which address should I provide to let my logger reading a correct values?

EDIT:
Just found solution. Registers provided by Sofar support are in DEC. It just need to be converted to HEX.
For example PV_Generation_Total is 0686 (dec) = 0x2AE (hex).
Just changed address from 0x0015 to 0x2AE and finally, the correct data is uploaded into Home Assistant

1 Like