michaluxpl / sofar_lsw3 Goto Github PK
View Code? Open in Web Editor NEWGet MODBUS data from Sofar (K-TLX) inverter through LSW-3 or LSE module
License: GNU General Public License v3.0
Get MODBUS data from Sofar (K-TLX) inverter through LSW-3 or LSE module
License: GNU General Public License v3.0
Is
Device information
Device serial number: 2768...
Firmware version: LSW3_15_270A_1.68
the right serial?
My serial begins with 2768...
Work your script with this serial?
Output:
Connecting to logger... connected successfully ! *** Chunk no: 0 Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x001\x83\x08\xa5\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15') Received data: b'\xa5c\x00\x10\x15\x00\x151\x83\x08\xa5\x02\x013z\x05\x00\x80\x05\x00\x00\xeb\xc0/e\x01\x03P\x00\x03\xff\xc1\x05\x81\xff\xff\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\x00*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x00\x00\x1d\x1f\xdd\x15' 0x0000 - Inverter status: "FAULT" 0x0001 - Fault 1: -63 0x0002 - Fault 2: 1409 0x0003 - Fault 3: -1 0x0004 - Fault 4: "ID50 Grid frequency sampling value between master and slave DSP vary widely" 0x0005 - Fault 5: "No error" 0x0006 - PV1 Voltage: 0.0V 0x0007 - PV1 Current: 0.0A 0x0008 - PV2 Voltage: 0.0V 0x0009 - PV2 Current: 0.0A 0x000A - PV1 Power: 0W 0x000B - PV2 Power: 0W 0x000C - Output active power: 0W 0x000D - Output reactive power: 0.0kVar 0x000E - Grid frequency: 0.0Hz 0x000F - L1 Voltage: 0.0V 0x0010 - L1 Current: 0.0A 0x0011 - L2 Voltage: 0.0V 0x0012 - L2 Current: 0.0A 0x0013 - L3 Voltage: 0.0V 0x0014 - L3 Current: 0.0A 0x0016 - Total production: 0kWh 0x0018 - Total generation time: 45h 0x0019 - Today production: 0Wh 0x001A - Today generation time: 42min 0x001B - Inverter module temperature: 0ºC 0x001C - Inverter inner termperature: 0ºC 0x001D - Inverter bus voltage: 0.0V 0x001E - PV1 voltage sample by slave CPU: 0.0V 0x001F - PV1 current sample by slave CPU: 0.0A 0x0020 - Countdown time: 50s 0x0021 - Inverter alert message: 0 0x0022 - Input mode: 0 0x0023 - Communication Board inner message: 0 0x0024 - Insulation of PV1+ to ground: 0 0x0025 - Insulation of PV2+ to ground: 0 0x0026 - Insulation of PV- to ground: 514 0x0027 - Country: "Germany"
Hi I have a DEYE SUN-8K-SG01LP1EU and looking for a solution to read out the values. I got your script working. But needed to change a lot of registers. Do you mind if I clone your code and create a new one?
./InverterData.py
Traceback (most recent call last):
File "./InverterData.py", line 11, in
import libscrc
ModuleNotFoundError: No module named 'libscrc'
Maybe file requirements.txt with depends packages will be resolve isssue.
I am getting the following error when I try to run this. Hope someone can help
Traceback (most recent call last):
File "InverterData.py", line 51, in <module>
os.chdir(os.path.dirname(sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory: ''
I tried running the code and get the error below.
Traceback (most recent call last): File "./InverterData.py", line 153, in <module> response=twosComplement_hex(str(''.join(hex(ord(chr(x)))[2:].zfill(2) for x in bytearray(data))+' '+re.sub('[^\x20-\x7f]', '', ''))[p1:p2]) File "./InverterData.py", line 20, in twosComplement_hex val = int(hexval, bits) ValueError: invalid literal for int() with base 16: ''
I'm running invertor Afore with LSW-3 logger.
Here is the error i got:
python ./InverterData.py
Connecting to logger... connected successfully !
Traceback (most recent call last):
File "/home/xxxx/Sofar_LSW3/./InverterData.py", line 140, in <module>
businessfield= binascii.unhexlify('0103' + pos_ini + pos_fin) # sin CRC16MODBUS
binascii.Error: Non-hexadecimal digit found
Logger Firmware version: LSW3_15_1E03_1.31
Device serial number: 2327xxxxxx
This is the registers definition from Afore:
AFORE_T4.pdf
Dzień dobry,
z góry przepraszam jeśli to jest złe miejsce na tego typu pytanie.
Ale proszę o wyrozumiałość.
Podpowie ktoś mniej więcej krok po kroku jak uruchomić tą integrację w HA? Mam instalację HA ściągniętą z oficjalnej strony zainstalowaną na rpi4, mqtt też mam i działa. Jednak nie wiem co dalej zrobić.
Mogę liczyć na jakąś podpowiedz? Próbowałem uruchomić inne integrację do sofara g3, i jest problem z pobieraniem danych z loggera, więc chciałbym to teraz dobrze zrobić i sprawdzić czy będzie działał. Bo jeśli nie to coś nie tak musi być z moją wersją. Już dwie integracja próbowałem i nie udało się. Działa jedynie pobieranie danych z chmury, ale jednak wolałbym lokalnie.
Pozdrawiam
Cześć Michale,
I've setup your script and get all the data from logger - that looks fine :)
Unfortunatelly almost every morning the script is kind of stuck. It does not collect any data untill I login to logger website and reset it:
Device information
Device serial number1774324xxx
Firmware versionLSW3_15_FFFF_1.0.57
The script is started by Synology NAS every minute. I does check if PV logger is pingable:
#!/bin/bash
PV_IP="hidden" # PV IP Address
PINGTIME=ping -c 1 -q $PV_IP | awk -F"/" '{print $5}' | xargs
echo $PINGTIME
if expr "$PINGTIME" '>' 0
then
echo "rozpoczynam odczyt danych ..."
python3 /volume1/docker/domoticz/scripts/sofar/InverterData.py
else
echo "brak komunikacji !!!"
fi
Any advice ?
Maybe some kind of timeout flag within python script would do the trick ?
Pozdrawiam
Mikołaj
Hi @MichaluxPL,
first of all, thank you for your script, good job! :-)
I'm trying your script on friends Sofar HYD 3000 and I find out a potential bug on line 138:
pos_ini=str(hex(pini)[2:4].zfill(4))
I used config value 0x0200 and this line translate it to 0020, which I think is wrong. Unfortunately I'm not python specialist, so I can't fix it, but If hardcore value 0200 to request, it is working.....
Thank you Ales
How does it work for you with the lines 157 and 158 of InverterData.py?
These lines:
pos_ini=str(hex(pini)[2:4].zfill(4))
pos_fin=str(hex(pfin-pini+1)[2:4].zfill(4))
with example configuration:
register_start1=0x0484
register_end1=0x0487
For pos_ini this will give the result 0048 instead of 0484 which I get correctly when I set range [2:5] .
Hello, can you briefly explain how I can get an integration into FHEM that retrieves the data regularly or live? Thanks very much
Help to convert to a Sunsynk/Deye Inverter??
Maybe i am missing something obvious:
I can access my Solarmax SGA converter (= SOFAR 1600K TL- G3) with the LSW-3 stick if i connect to the stick in AP mode, i.e. direct wifi connection to the stick. At the same time the stick has access to my regular wifi network and transmits everything to a server from Solarmanpv. So far so good..
If i connect to my wifi network myself and try to access the stick that way i get a timeout:
"Connecting to logger... Could not open socket - inverter/logger turned off"
My goal is to access the stick out of my normal local wifi network and stop it from sending data elswhere. Is that possible?
(Ser 235xxx, LSW3_15_FFFF_1.0.65, V1.1.00.0B)
Hi, I tried the script and it does connect successfully but the register offsets are not correct:
0x0000 - Inverter status: 21
No value in response for register 0x0001
Check register start/end values in config.cfg
How can I infer/find the correct values?
Thanks
edit:
I found out my inverter is a Sofar HYD-6000 ES which shares register addresses with the 3000:
https://github.com/MichaluxPL/Sofar_LSW3/files/7544510/SofarHYD.ES.ME3000SP.Modbus.protocol.pdf
Hello,
Do you know how to integrate that script with Domoticz? I see input in Mosuitto but I don't know how to add it to Domoticz
Witam, chciałem użyć tego skryptu do wysyłania danych do PVmonitor.pl, ale niestety nie może on zdekodować danych, aby zostały wyświetlone jak w przykładzie, tutaj wpis z konsoli:
Chunk no: 0
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00AW\x96h\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15')
Received data: b'\xa5c\x00\x10\x15\x00\x82AW\x96h\x02\x01\x08\x17\x94\x00\x90!\x00\x00\xb3\x14\xfa`\x01\x03P\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\xb7\x00C\x03#\x00\x00\x00\x19\x00\x00\x00\x15\xff\xbf\x13\x8a\t\x88\x00_\tv\x00_\t\x95\x00a\x00\x00\x0c"\x00\x00\n0\x00\x12\x00\x86\x00\x0e\x00\x1f\x19\xfa\x0e\xba\x03*\x00<\x00\x00\x00\x01\x00\x00\x04\xeb\x08.\x06\xab\x00\x0c\xff\xb5\n\x15'
Traceback (most recent call last):
File "F:\Pobrane\Przeglądarka\Sofar_LSW3-1.5\InverterData.py", line 169, in <module>
parameters=json.loads(txtfile.read())
File "C:\Users\xXx\AppData\Local\Programs\Python\Python39\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 7950: character maps to <undefined>
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
I'm having trouble entering records here. from sofar I have registers in a system other than hex how to replace it? which to choose for a given range 1,2,3. Do xml files need to be well-completed for the code to work without sending it to domoticz?
Witam, szukam przyczyny conajmniej dziwnego zachowywania pozyskanych danych lub ich braku w Domoticz.
Instancja Domoticz 2021.1 (build 13949) (Synology-Docker) - chcę pozyskać 12 danych z inwertera (Moc PV1,Moc PV2, Napięcie PV1, Napięcie PV2, Prąd PV, Prąd PV2, Dzienna produkcja, Całkowita produkcja, Moc czynna, Napięcie L1, Napięcie L2, Napięcie L3, Temperatura falownika, Temperatura modułu.
Wszystkie potrzebne virtualne urządzenia w Domoticz utworzone, skrypty poprawnie odpowiadają i wyświetlają się kompletne wyniki na terminalu - wszystko wygląda ok. Jednak raz tylko część danych pojawia się w Domoticz (np. 3 lub 2) , raz pojawiają się wszystkie które zostały skonfigurowane (12). Nie jest to regularne - zazwyczaj zawsze jest Napięcie PV1. Skrypt działa przez crone co 2 min. zmiana na inny czas np 10 min. też nie dała rezultatu.
Może jakiś pomysł?
Witam.
Udało się uruchomić integrację.
Jednak jest problem który polega na dziwnych danych.
Wygląda to tak:
user@debian~/SofarSolar/Sofar_LSW3$ python3 InverterData.py
Connecting to logger... connected successfully !
*** Chunk no: 0
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00F4\x17j\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15')
Received data: b"\xa5c\x00\x10\x15\x00uF4\x17j\x02\x01\x93\xf1\x03\x00\x8a\x08\x00\x00\x9f\x17'b\x01\x03P\x00\x03\xff\xc0\x05\x81\xff\xff\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ly\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<\x00\x0b\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc7\x00\x00\xe4v`\x15"
0x0000 - Status: "BŁĄD"
0x0001 - Kod błędu 1: -64
0x0002 - Kod błędu 2: 1409
0x0003 - Kod błędu 3: -1
0x0004 - Kod błędu 4: "ID50 Duża różnica w poziomie próbkowania częstotliwości pomiędzy nadrzędnym i podrzędnym DSP"
0x0005 - Kod błędu 5: "Brak błędów"
0x0006 - Napięcie PV1: 0.0V
0x0007 - Prąd PV1: 0.0A
0x0008 - Napięcie PV2: 0.0V
0x0009 - Prąd PV2: 0.0A
0x000A - Moc PV1: 0W
0x000B - Moc PV2: 0W
0x000C - Moc czynna: 0W
0x000D - Moc bierna: 0.0kVar
0x000E - Częstotliwość sieci: 0.0Hz
0x000F - Napięcie L1: 0.0V
0x0010 - Prąd L1: 277.69A
0x0011 - Napięcie L2: 0.0V
0x0012 - Prąd L2: 0.0A
0x0013 - Napięcie L3: 0.0V
0x0014 - Prąd L3: 0.0A
0x0016 - Całkowita produkcja: 0kWh
0x0018 - Całkowity czas pracy: 11h
0x0019 - Dzienna produkcja: 0Wh
0x001A - Dzisiejszy czas pracy: 11min
0x001B - Temperatura modułu: 0ºC
0x001C - Temperatura falownika: 0ºC
0x001D - Napięcie szyny falownika: 0.0V
0x001E - Napięcie PV1 próbkowane przez podrzędny CPU: 0.0V
0x001F - Prąd PV1 próbkowany przez podrzędny CPU: 0.0A
0x0020 - Czas próbkowania: 25s
0x0021 - Wiadomość alarmowa: 0
0x0022 - Tryb wejściowy: 0
0x0023 - Wewnętrzny komunikat szyny: 0
0x0024 - Izolacja PV1+ względem ziemi: 0
0x0025 - Izolacja PV2+ względem ziemi: 0
0x0026 - Izolacja PV- względem ziemi: 199
0x0027 - Kraj: "Niemcy"
*** Chunk no: 1
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00F4\x17j\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x10\x00\x10E\xc3\x00\x15')
*** Chunk no: 1
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00F4\x17j\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x10\x00\x10E\xc3\x00\x15')
*** Chunk no: 1
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00F4\x17j\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x10\x00\x10E\xc3\x00\x15')
*** Chunk no: 1
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00F4\x17j\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x10\x00\x10E\xc3\x00\x15')
^CTraceback (most recent call last):
File "/home/kuma/SofarSolar/Sofar_LSW3/InverterData.py", line 164, in <module>
data = clientSocket.recv(1024);
KeyboardInterrupt
user@debian:~/SofarSolar/Sofar_LSW3$
Na falowniku jest wszystko dobrze, brak błędów i praca normalna.
Inni z tego typu loggerem nie mają tego problemów.
W czym może być problem? Może wersja oprogramowania na loggerze?
Zestaw był zakupiony w luty tego roku.
i have 10 LSW-3
i tried your script against one, but i get
Connecting to logger... connected successfully ! *** Chunk no: 0 Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00\xcc\r=\xa4\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15') Received data: b'\xa5\x13\x00\x10\x15\x00r\xcc\r=\xa4\x02\x01\xb8\xb1\x8f\x00-&\x00\x00\xf7\xcd\xb3e\x01\x90\x02\xcd\xc1\xaf\x15' 0x0000 - Inverter status: -12863 0x0001 - Fault 1: -20715 No value in response for register 0x0002
The LSW-3 firmware version is LSW3_15_270A_1.6
Hi,
the current query (in grafana.ifdb.json, about line 850) gives negative values at start of each day, it can be addressed with a trick:
"query": "SELECT ((difference(max(\"SolarProduction_Today\")) + abs(difference(max(\"SolarProduction_Today\")))) / 2) FROM \"InverterData\" WHERE $timeFilter GROUP BY time(30m) fill(null)",
The trick just gets the absolute value and adds it to the first value, so it zeroes the negatives, then it divides by 2 to get the original positive values again.
HTH
Pere
I tried a lot of things with no luck. No answer from the wifi logger (LSW3_15_270A_1.32)
I got things like that with too short answer:
root@nuc:/sofarsolar/Sofar_LSW3-main# ./InverterData.py\x02\x00\x00F\x8aob\x01\x90\x02\x00\x03\\x15'
Connecting to logger... connected successfully !
*** Chunk no: 0
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00\x8d\xad,\x89\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00\x18E\xc0\x00\x15')
Received data: b'\xa5\x13\x00\x10\x15\x00\x0f\x8d\xad,\x89\x02\x01\xc6\xa6\x00\x00
0x0000 - Inverter status: "FAULT"
0x0001 - Fault 1: 23573
No value in response for register 0x0002
Check register start/end values in config.cfg
It would be so cool to get valid data, so I can do what I want like cool realtime graph ans stats.
It seems like the inverter sometimes sends invalid data (rarely but happens) which results in this script logging wrong values. Unfortunately we can't stop the inverter from doing that. However we can choose to ignore the invalid responses (at least I think so). This has happened to me 3 times but unfortunately I only have the raw response from one of the cases. However I believe it gives enough knowledge for implementing a fix.
The issue comes from that the script expects the response to have valid 0x03 function payload. For some reason, I've gotten at least one response where there's actually two 0x04 function payloads in front of the requested 0x03 function payload 🤔 I've removed some "personal" data from the images but here's an example of the valid response and one invalid response.
Possible things to fix the script from logging invalid values:
As a side note, while investigating this issue, I found this (kubaceg/sofar_g3_lsw3_logger_reader#12) from another logger reader. I believe it's caused by this same invalid data.
Hej,
Czy jest jakaś możliwość abyś zmienić typ licencji? Chciałbym użyć Twojego kodu (przepisać go na inny język) i użyć we własnym większym projekcie. Jednak nie mam w planach udostępniać kodu tej aplikacji. Dlatego stąd moje pytanie, czy dałoby się zamienić licencję na MIT? :)
Hi! Glad to see that someone did figure out how does protocol v5 works. I tried it on my inverter and I am getting such message:
Chunk no: 0
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00\xe1,\x1ah\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15')
Received data: b'\xa5c\x00\x10\x15\x00\x03\xe1,\x1ah\x02\x01\x0f\xa6/\x00H\x00\x00\x00\x00\x00\x00\x00\x01\x03P\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x128\x02\x81\x11\xf6\x02w\x01+\x01"\x028\xff\xbe\x13\x89\t$\x03-\t0\x03-\t\x1e\x03,\x00\x00\x07\xf9\x00\x00\x03V\x05\x01\x01(\x00*\x001\x19\x01\x12*\x11\xf2\x00<\x00\x00\x00\x01\x00\x00\x04\x9e\x0b\x02\t\x10\x00\x0ce=\xd9\x15'
Traceback (most recent call last):
File "C:\Users\Lenovo\Documents\Sofar_LSW3-main\InverterData.py", line 156, in <module>
parameters=json.loads(txtfile.read())
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python39-32\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 7950: character maps to <undefined>
The LWS serial numer is 174654****, FW: LSW3_14_FFFF_1.0.34
Inverter type is SF4ES008 (Sofar 8.8KTL-X) V2.40
I did try it on Windows with python 3.9.0 but can also check on linux later.
If you have any ideas what should I change to make it work I would be glad to hear them :D Thanks!
MichaluxPL, thanks for a great start with inverters via Wifi logger.
Would you like to make a similar module for the new G3 series inverters, could you share the WiFi Loggera protocol?
I searched the entire Internet, I can’t find anything ...
Maybe you can send it to the post office if you don’t want to post it for everyone: [email protected]
Thanks for this app, it's really appreciated since protocol v5 was a real blackbox until then.
There is one issue I have to report. The symbol used in xml file for temperature is probably wrong, it is now "º" U+00BA (masculine ordinal indicator), but this should be "°" U+00B0.
I am using this under FreeBSD. If there is real interest and more people are willing to run it under FreeBSD, will eventually create a port.
Please consider to add read/write support for the two mentioned registers. They are useful to control discharge of the battery. If enforced charging to a defined SoC could also be added this would be awesome.
ref. evcc-io/evcc#10379
Hi, firstly thanks very much for your hard work on this, very keen to get it working on my ME3000SP. I'm using Python in Windows 11
When I run the HWData script everything works fine, but when I run InverterData.py I get:
PS C:\Users\marti\OneDrive\Documents\Sofar_LSW3-main-v1-8\Sofar_LSW3-main> python3 .\InverterData.py
Connecting to logger... connected successfully !
*** Chunk no: 0
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00?\xf1\x13k\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15')
Received data: b'\xa5\x10\x00\x10\x15\x00/?\xf1\x13k\x02\x01w\x88L7M\r\x00\x00;p\xd0*\x05\x00\x9b\x15'
Traceback (most recent call last):
File "C:\Users\marti\OneDrive\Documents\Sofar_LSW3-main-v1-8\Sofar_LSW3-main\InverterData.py", line 186, in <module>
parameters=json.loads(txtfile.read())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 7995: character maps to <undefined>
I presume there is a character map issue going on here? Any suggestions please?
Please add another config option:
"mqtt_ssl": "bool"
and in InverterData.py add mqtt_ssl config reader and in if to mqtt ssl (it's broken when ssl isn't used:
if mqtt_ssl==1:
client.tls_set() # <--- even without arguments
after that mqtt payload is looks like:
inverter/attributes
{"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)":301.0,"PV1 Current (A)":0.93,"PV2 Voltage (V)":302.7,"PV2 Current (A)":0.88,"PV1 Power (W)":280,"PV2 Power (W)":260,"Output active power (W)":490,"Output reactive power (kVar)":-0.6,"Grid frequency (Hz)":50.04,"L1 Voltage (V)":231.9,"L1 Current (A)":1.14,"L2 Voltage (V)":234.0,"L2 Current (A)":1.13,"L3 Voltage (V)":231.6,"L3 Current (A)":1.12,"Total production (kWh)":6309,"Total generation time (h)":4532,"Today production (Wh)":330,"Today generation time (min)":72,"Inverter module temperature (oC)":18,"Inverter inner termperature (oC)":34,"Inverter bus voltage (V)":636.6,"PV1 voltage sample by slave CPU (V)":299.3,"PV1 current sample by slave CPU (A)":300.8,"Countdown time (s)":60,"Inverter alert message":0,"Input mode":1,"Communication Board inner message":0,"Insulation of PV1+ to ground":1338,"Insulation of PV2+ to ground":1945,"Insulation of PV- to ground":1570,"Country":"Poland","String 1 voltage (V)":11.4,"String 1 current (A)":23.4,"String 2 voltage (V)":11.3,"String 2 current (A)":23.16,"String 3 voltage (V)":11.2,"String 3 current (A)":0.0,"String 4 voltage (V)":630.9,"String 4 current (A)":0.0,"String 5 voltage (V)":453.2,"String 5 current (A)":0.33,"String 6 voltage (V)":7.2,"String 6 current (A)":0.18,"String 7 voltage (V)":3.4,"String 7 current (A)":63.66,"String 8 voltage (V)":299.3,"String 8 current (A)":30.08}
we tried to run the script. Once with a Dietpi and once directly on the Synology, both without success.
We use an Azzurro hybrid inverter with the LSW-3 module.
Is there a possibility that we may ask for your help?
Hi
I tried to connect to my LSE-3 logger (eth type),but I get these message:
No value in response for register 0x0000
Check register start/end values in config.cfg
But I have no clue about these register start/end values
Device serial number 210xxxxxxx
Firmware version ME_0C_270A_1.05
When I run InverterHWData.py I get:
Traceback (most recent call last):
File "path\InverterHWData.py", line 120, in <module>
val1=chr(int(str(responsereg[0:2]),16))
ValueError: invalid literal for int() with base 16: ''
Hey,
Is it possible for you to drop here a manual with the addresses of all holding registers? I searched on "elektroda.pl", but there is no overlap between these addresses from the script and their pdf.
How to identify the protocol version?
Hi,
I tried Your script to communicate with for inverter HYD3000-ES but with no luck. After execution I see following output.
python3 ./InverterData.py
Chunk no: 0
Sent data: bytearray(b'\xa5\x17\x00\x10E\x00\x00\x86soh\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15')
Received data: b'\xa5\x10\x00\x10\x15\x00\xb7\x86soh\x02\x010E\x00\x00\x9b\x19\x00\x001\xfe\x8ca\x05\x00\t\x15'
0x0000 - Status: 21
No value in response for register 0x0001
Check register start/end values in config.cfg
python3 ./InverterHWData.py
Modbus request: 0104 2000 000e 7a0e
Hex string to send: A5 1700 1045 0000 86736f68 020000000000000000000000000000 01042000000e7a0e 00 15
Data sent: bytearray(b'\xa5\x17\x00\x10E\x00\x00\x86soh\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x04 \x00\x00\x0ez\x0e\x00\x15')
Data received: b"\xa5/\x00\x10\x15\x00\xb6\x86soh\x02\x01'E\x00\x00\x92\x19\x00\x001\xfe\x8ca\x01\x04\x1c\x00\x05SM1ES130LBL394V260V100V260X\xb9\x81\x15"
Hex string received: A5 2F 00 10 15 00 B6 86 73 6F 68 02 01 27 45 00 00 92 19 00 00 31 FE 8C 61 01 04 1C 00 05 53 4D 31 45 53 31 33 30 4C 42 4C 33 39 34 56 32 36 30 56 31 30 30 56 32 36 30 58 B9 81 15
Register: 0x2000 , value:0005 ()
Register: 0x2001 , value:534d (SM)
Register: 0x2002 , value:3145 (1E)
Register: 0x2003 , value:5331 (S1)
Register: 0x2004 , value:3330 (30)
Register: 0x2005 , value:4c42 (LB)
Register: 0x2006 , value:4c33 (L3)
Register: 0x2007 , value:3934 (94)
Register: 0x2008 , value:5632 (V2)
Register: 0x2009 , value:3630 (60)
Register: 0x200A , value:5631 (V1)
Register: 0x200B , value:3030 (00)
Register: 0x200C , value:5632 (V2)
Register: 0x200D , value:3630 (60)
{
"Moc falownika": "15kW",
"Numer seryjny": "SM1E30LBLxxx",
"Wersja oprogramowania": "V260",
"Wersja sprzętowa": "V100",
"Wersja DSP": "V260"
}
SN is correct, inverter_sn=175xxxxxxx
Moc falownika is incorrect (should be 3 kW hybrid).
Can you help me with this issue ?
p.s. I found here: https://github.com/cmcgerty/Sofar2mqtt/blob/main/HYBRID/HYBRID.ino some ModBus addresses - reported as working with hybrid inverters. Can you check it ?
The script does not recognize statuses correctly, it always sends "normal".
For example, at the end of the day, the inverter goes into standby, so the script should send "stand-by".
Hi,
I got logger with sn starts with 23xxxxxxx, wondering from where you have obtained the addresses of registres from supported devices?
Zauważyłem dwa małe błędy.
Hi MichaluxPL,
i've been using & testing your scripts for about 6 weeks, I have a Sofar 1100tl-g3. Very strange values have been coming from the inverter for about 4 days, I rather suspect that this problem is with the inverter because the wrong values are already displayed there in the dashboard / status page.
Here are a few pictures of it, the inverter thinks I have already generated 22kwh today or 51kwh yesterday :-)
Which is not possible even in the very best location with 3x400w modules :-)
It is strange that ~ every 2 hours the values on the inverter are increased. (seeing picture from yesterday)
Have you ever seen some of these problems?
Yesterday:
Hello, I got some chinese inverter INVT BD6TKL-RL1 and LSW3_15_840B_1.24 ( SN 234xxxxxxxxxxxx)
The problem is when i try to use the script it only gives me one single value and its -16143 ( b'\xa5\x13\x00\x10\x15\x00\x02\xe3\xa6~\x8b\x02\x01\x7fmQ7\xf6\n\x00\x00\xd8V\x03-\x01\x83\x02\xc0\xf1\xd8\x15' ) and i think its kind of error that i cannot understand? Can u please help
Po uruchomieniu skryptu na linux'ie otrzymałem komunikat:
admin@nas:~/DeyeInverter-main$ **sudo python InverterData.py**
Traceback (most recent call last):
File "InverterData.py", line 18, in <module>
os.chdir(os.path.dirname(sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory: ''
Zakomentowałem 18 linię i uruchomiłem ponownie i otrzymałem błąd:
Traceback (most recent call last):
File "InverterData.py", line 108, in <module>
response=twosComplement_hex(str(''.join(hex(ord(chr(x)))[2:].zfill(2) for x in bytearray(data))+' '+re.sub('[^\x20-\x7f]', '', ''))[p1:p2])
File "InverterData.py", line 13, in twosComplement_hex
val = int(hexval, bits)
ValueError: invalid literal for int() with base 16: ''
Wstawiłem w kodzie print ze zmiennej "data" i dostaję wynik:
0
DATA:
b"\xa5\x10\x00\x10\x15\x00<\xa0\x1fjf\x02\x01@f\x98\x00/\x0e\x00\x00'\x13\xbc`\x05\x00\xd9\x15"
0x003B-Running Status:21
Traceback (most recent call last):
File "InverterData.py", line 110, in <module>
response=twosComplement_hex(str(''.join(hex(ord(chr(x)))[2:].zfill(2) for x in bytearray(data))+' '+re.sub('[^\x20-\x7f]', '', ''))[p1:p2])
File "InverterData.py", line 13, in twosComplement_hex
val = int(hexval, bits)
ValueError: invalid literal for int() with base 16: ''
Mój konfig:
[DeyeInverter]
inverter_ip=10.0.0.55
inverter_port=8899
inverter_sn=1718230944
mqtt=0
mqtt_server=10.0.0.111
mqtt_port=1883
mqtt_topic=sofar
mqtt_username=home
mqtt_passwd=xxx
Co może być nie tak?
Pozdrawiam,
Paweł
Hi,
Thanks for sharing your code for this :) sorry if this is a school boy question... relatively new to python programming.
I'm trying to get the realtime usage statistics out of our Sofar HYD3000-ES inverter via the LSW3 wifi dongle, I've been able to get the hardware information as below:
{
"Product code": "15kW", <---- This happens to be incorrect :-/. it's a 3kW Inverter :-/
"Serial Number": "SMxxxxxxxxx",
"Software Version": "V260",
"Hardware Version": "V100",
"DSP Version": "V260"
}
But when I try to extract the statistics I'm getting
No value in response for register 0x0001
Check register start/end values in config.cfg. <-- This is left as the default register_start1=0x0000 & register_end1=0x0027, noted you say you may need to change this to work with other inverters? is there a way to discover what this should be?
I suspect the issue may actually be with the Data Logger rather than the code :-/ as the Yield and power values are shown as 0.0 kWh (as per image below) despite uploading the correct figures into Solarman :-/ think this is likely a firmware problem but cant locate any firmware downloads.
Just wondering if you've seen the 'No value in response for register 0x0001' error before or have experience / any ideas with the HYD range of inverters? before I pursue the lack of yield information issue with Solarman / Sofar.
Many Thanks!
Phil
I get the following error.
Traceback (most recent call last):
File "/home/pi/Sofar_LSW3/InverterData.py", line 315, in <module>
client=paho.Client("inverter")
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/Sofar_LSW3/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 772, in __init__
raise ValueError(
ValueError: Unsupported callback API version: version 2.0 added a callback_api_version, see docs/migrations.rst for details
hope you can help
Hi! Does your solution work on a Samil TL inverter? How should I configure it? Please let me know 🙏
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.