jmccrohan / pysolarmanv5

A python module to interact with Solarman Data Logging Sticks
MIT License
116 stars 25 forks source link

V5 frame does not contain a valid Modbus RTU frame #48

Closed d-eggert closed 6 months ago

d-eggert commented 6 months ago

I setup the all-in-one deye solution DEYE-AI-W5.1-12P3-EU-ESS (LV). It also included a wifi datalogger for solarman. So I tried to integrate it into homeassistant via the solarman HACS integration. While the entities are created, the values are not updated.

After some research I ended up in this repo and tried the solarman_scan.py util, which successfully found the data logger. I also ran the client_example.py but got the following traceback:

DEBUG:pysolarmanv5.pysolarmanv5:Socket setup completed... <socket.socket fd=220, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.150', 57058), raddr=('192.168.1.175', 8899)>
DEBUG:pysolarmanv5.pysolarmanv5:SENT: a5 17 00 10 45 0b 00 e4 7c c3 a1 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 04 80 fe 00 06 38 38 36 15
DEBUG:pysolarmanv5.pysolarmanv5:RECD: a5 10 00 10 15 0b 1e e4 7c c3 a1 02 01 c2 0f 01 00 58 13 00 00 bb ed 84 65 05 00 f8 15
Traceback (most recent call last):
  File "C:\workspace\pysolarmanv5\examples\client_example.py", line 45, in <module>
    main()
  File "C:\workspace\pysolarmanv5\examples\client_example.py", line 17, in main
    print(modbus.read_input_registers(register_addr=33022, quantity=6))
  File "C:\workspace\pysolarmanv5\pysolarmanv5\pysolarmanv5.py", line 515, in read_input_registers
    modbus_values = self._get_modbus_response(mb_request_frame)
  File "C:\workspace\pysolarmanv5\pysolarmanv5\pysolarmanv5.py", line 410, in _get_modbus_response
    mb_response_frame = self._send_receive_modbus_frame(mb_request_frame)
  File "C:\workspace\pysolarmanv5\pysolarmanv5\pysolarmanv5.py", line 398, in _send_receive_modbus_frame
    mb_response_frame = self._v5_frame_decoder(v5_response_frame)
  File "C:\workspace\pysolarmanv5\pysolarmanv5\pysolarmanv5.py", line 261, in _v5_frame_decoder
    raise V5FrameError("V5 frame does not contain a valid Modbus RTU frame")
pysolarmanv5.pysolarmanv5.V5FrameError: V5 frame does not contain a valid Modbus RTU frame

Looks somewhat similar to #18 . Is there a chance we get this fixed? I'm happy to assisst.

jmccrohan commented 6 months ago

Hi @d-eggert,

client_example.py is just that, an example. You'll need to amend the Modbus registers to suit your own specific inverter. (As it happens, it contains valid Modbus registers for a Solis Hybrid inverter, as that is what I have myself).

Based on the DEBUG logs you've posted above, you sent a Modbus RTU request of 01 04 80 fe 00 06 38 38 (I've decoded it below using this tool) and received an invalid response from the inverter of 05 00. Based on this, pysolarmanv5 appears to be functioning as per spec.

Cheers, Jon

Part of Data Package Description Value
01 Slave address 0x01 (1)
04 Function code 0x04 (4) - Read Input Registers
80 FE Starting address Physical: 0x80FE (33022) Logical: 0x80FF (33023)
00 06 Quantity 0x0006 (6)
38 38 CRC 0x3838 (14392)