StephanJoubert / home_assistant_solarman

Home Assistant component for Solarman collectors used with a variety of inverters.
Apache License 2.0
524 stars 194 forks source link

Switched from wireless lan logger LSW-3 to cable logger LSE-3 #247

Open hasant73 opened 1 year ago

hasant73 commented 1 year ago

I first tried the LSW-3 logger and I could connect with home assistant to the logger and get data. But I don't have good WLAN in the cellar where the inverter is installed. So I switched from the wireless version to the LAN cable version called LSE-3. LSE-3 is reporting to solarmanpv website successfully. But Home Assistant doesn't want to connect anymore. Does somebody know if there is a setting I need to change or have any other idea what's wrong.

I have changed the serial number of the logger in the config. Otherwise I use the deye_sg04lp4.yaml file. I entered the IP address of the logger and setup the network that it is always the same IP address. I can also reach the configuration web page of the logger.

The number of the serial number starts with 21...

MartinNeurol commented 1 year ago

Hi, I second this - got LSE3 wired logger and so far was unable to connect it to HASS at all. I Will gladly serve as a sandbox for LSE3 integration testing :) (SN 21xxxxxxxx...) firmware MW4C_14_CSIP_1.14

LOG: (recurring messages) Logger: custom_components.solarman.solarman Source: custom_components/solarman/solarman.py:173 Integration: Solarman ([documentation] First occurred: 19. března 2023 v 19:34:43 (1104 occurrences) Last logged: 15:04:20

Querying registers [3 - 89] failed, aborting.

hasant73 commented 1 year ago

It looks like the stick has port 8899 open:

`Starting Nmap 7.80 ( https://nmap.org ) at 2023-03-20 15:43 CET

Nmap scan report for solarman-logger.fritz.box (192.168.178.125)

Host is up (0.0029s latency).

Not shown: 998 closed ports

PORT STATE SERVICE

80/tcp open http

8899/tcp open ospf-lite`

Matz88 commented 1 year ago

I read in other issues that this integration supports only the WiFi dongles, some had success with the beta version, but most not. Search for "ethernet" in the issues. If you find a way, please tell me!

sanderbaks commented 1 year ago

I have the same issue :(

sanderbaks commented 1 year ago

I still did not get it to work? Did anyone find a solution?

Matz88 commented 1 year ago

If you have the LAN adapter, just try the SolaX Power Modbus custom_component

sanderbaks commented 1 year ago

Ow, Ok, lets try that!! I'll let y'all know the results

McLP11 commented 1 year ago

I have the same logger LAN and I cannot as well use this integration, values always unknown. right now the only solution I found, as reported also above, is with SolaX Power modes integration.

adnovea commented 1 year ago

I have the same problem. I cannot read Modbus from Deye SUN 5K sg03lp1 inverter with a LSE-3 Stick logger. The LAN LSE-3 logger (s/n 21xxxxxxxx) works well with Solarman website but returns incorrect data from local requests based on Solarman V5 protocol.

For example, a request for battery voltage (reg:0x00B7) gives me :

        Tx Packet: a5 1700 1045 ad00 [s/n] 02 0000 00000000 00000000 00000000 01 03 00b7 0001 342c bc 15
    Rx Packet: a5 1700 1045 03 00 bc 02

The return packet is way too short , should have 1015 instead of 1045 and length-byte is wrong.

With LSW-3 logger the response is :

      Rx Packet:  a5 1500 1015 ab3d [s/n] 02 01 5d510000 04070000 00000000  01 03 02 14c7 f6d6 e4 15

where 0x14C7=5319 is exactly my battery voltage x0.01 (53.19V)

Does anyone have any idea where to look?

adnovea commented 1 year ago

McLP11, could you tell more about the use of SolaX Power modes integration with LSE-3 and Deye ? Thanks

McLP11 commented 1 year ago

@adnovea right now SolaX Inverter Modes looks like the only integration I was able to connect with my LSE-3 LAN dongle. It exposes 159 sensors, including also some switches or specific tools for configuration but not tested yet at all. It's pretty stable, I've just noticed that sometimes is not back online when you restart HA, new restart and back again

adnovea commented 1 year ago

Thanks McLP11 for your reply. I'm trying to understand what is different between SolaX and Solarman to make the LSE-3 working. Is SolaX using a portal and an API ? What I'm looking for, is local communicate with my Inverter using the LSE-3 on my local network only (not using the Solarman Cloud portal API). This was possible with the LSW-3. Which version of SolaX have you installed, the one I used with HAC is SolaX Inverter Modbus and expose only 4 sensors and I cannot connect to my Deye using the SolaX Power integration.

adnovea commented 1 year ago

I can communicate with the inverter using the LSE-3 Stick Logger and the GModbus RTU/TCP tester (free) application (https://www.gineers.com/media/downloads/GModbus.zip). The LSE-3 supports RAW Modbus RTU/TCP without the V5 Solarman encapsulation.

Device tested on DEYE Sun-5K-SG03LP1-EU:

LSE-3 Stick Logger S/N: 21xxxxxxxx F/W: MW4C_14_CSIP_1.14 Extended system version: ME_0D_5406_4.07

GModbus log:

    Connected TCP/IP, at 08:54:01
    Send: 03 E8 00 00 00 06 01 03 00 55 00 02 
    Received: 01 03 04 01 03 00 00 0B CF 
    Disconnected TCP/IP connection at 08:54:10

LSE-3 support "raw" Modbus RTU/TCP (I ran a small PHP script to do my tests)

Example: FC3 read Single Register: REG=85 NB=2

Status: Connected
Tx Packet: 03e800000006010300550002d41b
Rx Packet: 03e80000000701030401030000

Request for Total Load Consumption register reading :
    03E8: Transaction identifier
    0000: Protocol identifier
    0006: Message length 
      01: Slave ID
      03: Read function (Holding)
    0055: 1st register address
    0002: Number of register to read
    D41B: CRC-16 ModBus with little Endian

Answer from Total Load Consumption register :
    03E8: Transaction identifier
    0000: Protocol identifier
    0006: Message length 
    0103: Value LSB
    0000  Value MSB  ==> 25.9 kWh

Example: FC3 read Multiple Registers 3-112: REG=0003 NB=110

    Request send: 
            03e8: Transaction identifier
            0000: Protocol identifier
            0006: Message length (w/o CRC)
              01: Slave ID
              03: Read function
            0003: 1st register address
            006e: Nb of registers to read 
            3426: CRC-16 ModBus

    Received data: 
            03e8: Transaction identifier
            0000: Protocol identifier
            00df: Message length 
              01: Slave ID
              03: Read function
              dc: Number of bytes read (220)
            3232: Inverter ID [reg 0003] - ASCII values (22......)
            ....
sanderbaks commented 1 year ago

This is great to hear. I am following this development!

adnovea commented 1 year ago

[SOLVED] I have modified the Solarman code to reflect the LSE-3 protocol changes.
As mentioned above, the Ethernet LSE-3 Stick Logger does not implement the V5 encapsulation (probably used as an additional security in the Wifi transmission protocol of the LSW-3).

To use the LSE-3 (version S/N: 21xxxxxxxx) with the Stephane's component, you may first backup the 2 files solarman.py & parser.py located in the _config\customcomponents\solarman folder and then apply the modifications below using the File Editor.

parser.py:


(line 5)
#ADNOVEA FIX begin
# OFFSET_PARAMS = 28
OFFSET_PARAMS = 9
#ADNOVEA FIX end

solarman.py

(line 15)
# ADNOVEA FIX begin
# SERIAL_NO = [0x00, 0x00]
SERIAL_NO = [0x03, 0xE8]
PROTOCOL_BYTE = [0x00, 0x00]
#ADNOVEA FIX end

(line 66)
    def generate_request(self, start, length, mb_fc):
#ADNOVEA FIX begin
#        packet = bytearray([START_OF_MESSAGE])
        packet = []
        packet.extend(SERIAL_NO)

        packet_data = []
        packet.extend(PROTOCOL_BYTE)
#        packet_data.extend (SEND_DATA_FIELD)
        buisiness_field = self.get_read_business_field(start, length, mb_fc)
        packet_data.extend(buisiness_field)
#        length = packet_data.__len__()
        length = packet_data.__len__() - 2
#        packet.extend(length.to_bytes(2, "little"))
        packet.extend(length.to_bytes(2, "big"))
#        packet.extend(CONTROL_CODE)
#        packet.extend(SERIAL_NO)
#        packet.extend(self.get_serial_hex())
        packet.extend(packet_data)
        #Checksum
#        checksum = 0
#        for i in range(1,len(packet),1):
#            checksum += packet[i]
#        packet.append(checksum & 0xFF)
#        packet.append(END_OF_MESSAGE)
#ADNOVEA FIX end

        del packet_data
        del buisiness_field
        return packet

(line 164)
    def send_request(self, params, start, end, mb_fc, sock):
        result = 0
        length = end - start + 1
        request = self.generate_request(start, length, mb_fc)
        try:
#ADNOVEA FIX begin
            # log.debug(request.hex())
            # log.debug('[send_request] send data: %s', bytes(request).hex())
            # sock.sendall(request)
            sock.sendall( bytes(request) )
            raw_msg = sock.recv(1024)
            # log.debug(raw_msg.hex())
            # log.debug('[send_request] received data: %s', bytes(raw_msg).hex())
#            if self.validate_packet(raw_msg) == 1:
#                result = 1
#                params.parse(raw_msg, start, length)
#            else:
#                log.debug(f"Querying [{start} - {end}] failed, invalid response packet.")
#ADNOVEA FIX end
            result = 1
            params.parse(raw_msg, start, length)
            del raw_msg
        finally:
            del request
        return result

    @Throttle (MIN_TIME_BETWEEN_UPDATES)
    def update (self):
        self.get_statistics()
        return
adnovea commented 1 year ago

Dear Stephane, Would you mind to add this protocol to your component in order to support the Ethernet LSE-3 (S/N 21xxxxxxxx) with a selectable "V5 Encapsulation" option. We will be grateful for this update and again a big thank you for your great work. Par avance, Merci.

gmbh07 commented 1 year ago

I have an zcs azzurro 80 ktl-v3 and the lse-3 Ethernet adapter, but I can't connect. can you help me, I tried your solution but it dosent work.

adnovea commented 1 year ago

Is your LSE-3 S/N in 21xxxxxxxx ? Do you have a LSW-3 module and is it working ?

Python indentation is very critical and you better replace Tabs by Spaces. You can enable the HA debug mode and check the log to see if there is problem with the Solarman modified code

To check if the LSE-3 communication is working download the GModbus application (https://www.gineers.com/media/downloads/GModbus.zip) and run :

If this fails, my mods cannot work for you.

gmbh07 commented 1 year ago

My LSE-3 S/N is in 21xxxxx, I don't have a LSW-3 module because there is no WLAN at this place. I tried the GModbus application with your settings and get something back, look at the picture.

Screenshot 2023-06-21 142624

adnovea commented 1 year ago

The GModbus results are encouraging. Your communication to the inverter using the LSE-3 stick logger is successful. If you found in the HA log errors such as "Querying [0x0400 - 0x042B] failed..." it's probably a typo issue. Check the code indentation.

gmbh07 commented 1 year ago

I checked the code and make it all new, now it works for me, thanks for you solution. is there a way to read the modbus register? In the azzurro.yaml there are only two sensors of the strings, and the 80ktl-v3 have some more. By google I didn't found the full modbus register for zcs azzurro

adnovea commented 1 year ago

Great ! I'm glad the mods works. You can read any Azzuro Modbus Register using the GModbus application:

Your string sensors are registers are :

You can try to read register from 0x058A (1418) to 0x58F (1423) and check if the data pattern looks like the PV1/PV2 ones. Often, strings data are next to each other. Sorry, I cannot help you more about the Azzurro.

adnovea commented 1 year ago

Modification for LAN LSE-3 Stick Logger module using raw Modbus RTU protocol I failed to make the mods working because I have no experience in Python coding. In _configflow.py I added the following line:

 vol.Optional(CONF_LOOKUP_PROTOCOL, default=data.get(CONF_LOOKUP_PROTOCOL)): vol.In(LOOKUP_PROTOCOL),

but I cannot correctly retrieve the protocol radio-button value in the Solarman code. Could someone help ? Thanks.

image

michaelcorradi commented 1 year ago

I have the same issue. I can't communicate in any way, all parameters remain at "Unknown". I tried to follow different configurations but I can not solve.

My configuration is:

Does anyone have an idea how to fix it?

michaelcorradi commented 1 year ago

folder and then apply the modifications below using

@adnovea Does this solution work?

adnovea commented 1 year ago

May I suggest you to follow the steps below:

  1. Find the Modbus register list (Internet search) corresponding to your Inverter (https://github.com/StephanJoubert/home_assistant_solarman/files/10187824/solarman-ZCS_HYD-6000.txt)
  2. Use GModbus utility to test some registers and validate the list.
  3. Check if the file zcs_azzurro-ktl-v3.yaml has the correct register values. If not, update the YAML file according to your Inverter registers (_you can create a copy of the zcs_azzurro-ktl-v3.yaml file into a file named custom_parameters.yaml and select this file in the HA Solarman module configuration_).
  4. Modify the Solarman module files parser.py and solarman.py as I mentioned above (create backup files to roll back if needed).

If you succeed in the steps above, you'll be able to retrieve data from your inverter.

N.B. If you encounter some troubles connecting with GModbus, may be your stick logger F/W need to be updated. You can email the customer service at Solarman customerservice@solarmanpv.com and they will do the update remotely.

see also https://github.com/StephanJoubert/home_assistant_solarman/discussions/148

adnovea commented 1 year ago

Yes my mods works with Deye and has been used with Azzuro inverter by gmbh07. Copy the _solarman-ZCSHYD-6000.txt above into _customparameters.yaml, apply the modifications, then select the _custom_parameters.yamlfile in HA Solarman module and full reboot HA.

gmbh07 commented 1 year ago

the solution from adnovea for my azzurro and LSE-3 is still working with no problems

michaelcorradi commented 11 months ago

@adnovea with your suggestion my configuration is working.

My configuration is:

I'm using the configuration "zcs_azzurro-ktl-v3.yaml" is the only one that works, but I see only few values updated.

What is the best configuration I can use? Since your code works, can't the developer @StephanJoubert upload it to the official library?

adnovea commented 11 months ago

Hi Michael,

Glad to see that the mods is working with your config. I hope @StephanJoubert will update the code for supporting the LSE-3.

Have you tried to download the configuration file at https://github.com/StephanJoubert/home_assistant_solarman/files/10187824/solarman-ZCS_HYD-6000.txt ? Did it expose more values ?

michaelcorradi commented 11 months ago

@adnovea I tried to put the content fo your txt file in "custom_parameters.yaml" (27 entities) but the communication does't work. I wait for some minute but it remain Disconnected.

adnovea commented 11 months ago

Once you have : 1- created the "_customparameters.yaml" 2- fully restarted HA 3- cleared the browser 4- and re-logging to HA, you should have 27 entities exposed by the integration.

If this still fails, try to communicate with you inverter using GModbus (see above how to run this utility). Attention: register values shall be entered as decimal (not Hex) values.

maartenba commented 11 months ago

For ME3000-SP and the LSE-3, using the sofar_wifikit preset and changes by @adnovea (https://github.com/StephanJoubert/home_assistant_solarman/issues/247#issuecomment-1591817882) worked wonders.

maartenba commented 11 months ago

Change seems to be incompatible with 1.5.0 because of a switch to pysolarmanv5. @adnovea not sure if you know how to work around that? I'm happy to open a pull request with a enable/disable V5 encapsulation toggle, though for 1.5.0 I'm not sure how to disable V5 anymore.

adnovea commented 11 months ago

Hi maartenba,

I made the mods for 1.0.0. Basically the LSE-3 support a RAW Modbus protocol. To support the LSE-3 module, the V5 solarman protocol which encapsulates the RAW Modbus data just need to be made optional. My mods was only commenting the code line of the encapsulation.

I'm sure Stephan know how to do this but I'll be please to help when time permits.

Mocky158 commented 9 months ago

I would like to ask if someone would be willing to upload modified files here for use by LSE, somehow I can't do it. Thank you very much .

adnovea commented 9 months ago

Hi Mocky158, I'm creating a repo _solarmanlse with a fork from the nice Stephan's Add-on to support the LSE stick loggers. The purpose of this repo is mainly to share a quick solution for those with LSE Stick Logger. It is compatible with the inverter_definitions and provides a more flexible solution for Deye Sun 5K with possibility to write registers. For other inverters, owner should dig in the inverter Modbus register documentation to find the corresponding codes and values (BE CAREFUL because this can definitely damage the inverter).

Niklas1E commented 7 months ago

@adnovea

You describe here (https://github.com/StephanJoubert/home_assistant_solarman/issues/247#issuecomment-1590665761) that you adapt two files (parser.py and solarman.py) and the LAN dongle then works on the DEYE SUN? Maybe I'm being very stupid, but I can't find the values in the two files. My dad has the DEYE SUN and I want to help him integrate it into HomeAssitant.

THX

adnovea commented 7 months ago

Niklas1E, the last version of Solarman use the Solarman library instead of the files mentioned above. That's the reason why I had to fork this project into the repo _solarmanlse.

Niklas1E commented 7 months ago
            Thank you very much!Can I damage anything on the inverter with the add-on?Or does it only read data or does it also write data?Sorry, I'm an amateur.Am 20.01.24 um 08:23 schrieb AdNovea®

                Von: "AdNovea®" ***@***.***>Datum: 20. Januar 2024An: "StephanJoubert/home_assistant_solarman" ***@***.***>Cc: "Comment" ***@***.***>,"Niklas1E" ***@***.***>Betreff: Re: [StephanJoubert/home_assistant_solarman] Switched from wireless lan logger LSW-3 to cable logger LSE-3 (Issue #247)

Niklas1E, the last version of Solarman use the Solarman library instead of the files mentioned above. That's the reason why I had to fork this project into the repo solarman_lse.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

adnovea commented 7 months ago

There is always a risk when you don't perfectly understand what you do. Read carefully all the instructions. This is not a "plug&play" module. It has not been tested with many inverters nor fully debugged. I just share what I'm currently using for my Deye Sun 5K but you must understand what you are doing. As long as you avoid writing to the inverter registers, the risk is limited. Do not use "switch/select" entities to prevent sending unexpected commands and keep only "sensor" registers.

Imanol82 commented 4 months ago

Hello @adnovea . I'm in the same situation. Deye Sun 6K, with LSE-3 SN: 21***

1- created the "custom_parameters.yaml" 2- IP ans SN: image 3- Configuration in HA: image 4- Result: image

Why? What I'm doing wrong? Thank you very much!

adnovea commented 4 months ago

Imanol82 did you read the whole post ? I explain above why the Stepan module does not work with LSE module and what can be done to solve the problem. The current version cannot be modified for LSE and you need to tune the add-on with my solarma_lse fork.

Imanol82 commented 4 months ago

Thank you very much!

I'm very new in HA... I'll try mod.

:)

70sxorpio commented 3 months ago

Hello. I have an Afore BNT004KTL inverter with LSE-3 logger serial number 21xxxxxxxx and no configuration works in homeassistant. Does anyone have this inverter connected? Please help.

MartinNeurol commented 2 months ago

There is always a risk when you don't perfectly understand what you do. Read carefully all the instructions. This is not a "plug&play" module. It has not been tested with many inverters nor fully debugged. I just share what I'm currently using for my Deye Sun 5K but you must understand what you are doing. As long as you avoid writing to the inverter registers, the risk is limited. Do not use "switch/select" entities to prevent sending unexpected commands and keep only "sensor" registers.

Hi! I am using the Solarman LSE for my SUN-10K-SG04LP3-EU. Everytime I set up the interation, in less then 24 HRS, my inverter falls into COM error and has to be restarted. That never happens when the integration is off. As I am using LSE version and my neigbor literally has the same solution, but with standard Solarman integration and wireless logger working just fine, I am just asking - where to look, who to ask? Or ditch it? Many thanks, Martin

adnovea commented 2 months ago

Hi MartinNeurol,

It seems your are using the Solarman_LSE add-on therefore I replied to your post at thread.