jblance / mpp-solar

Python package to communicate to MPP Solar PIP-4048MS inverters (and similar)
MIT License
364 stars 151 forks source link

Run command Received Status_todo #140

Closed irmajavi closed 1 year ago

irmajavi commented 3 years ago

Hi I run this command: rock64@rock64:~$ mpp-solar -P PI16 -c QPIGS -p /dev/ttyUSB0

2021-08-16 20:08:10,989:WARNING:abstractprotocol:process_response@161: Failed to eval format bytes.decode(raw_value), error: descriptor 'decode' requires a 'bytes' object but received a 'str'
Command: QPIGS - General status query
------------------------------------------------------------
Parameter                       Value           Unit
grid_voltage                    0               V
output_power                    0               W
grid_frequency                  0               Hz
output_current                  0               A
ac_output_voltage_r             0               V
ac_output_power_r               0               W
ac_output_frequency             0               Hz
ac_output_current_r             0               A
output_load_percent             0               %
pbus_voltage                    0               V
sbus_voltage                    0               V
positive_battery_voltage        0               V
negative_battery_voltage        0               V
battery_capacity                0               %
pv1_input_power                 0               W
pv2_input_power                 0               W
pv3_input_power                 0               W
pv1_input_voltage               0               V
pv2_input_voltage               0               V
pv3_input_voltage               0               V
max_temperature                 0               °C
status_todo                     bytes.decode(raw_value)

rock64@rock64:~$ rock64@rock64:~$ mpp-solar -P PI16 -c QPIGS -p /dev/ttyUSB0

ac_output_frequency             0               Hz
ac_output_current_r             0               A
output_load_percent             0               %
pbus_voltage                    0               V
sbus_voltage                    0               V
positive_battery_voltage        0               V
negative_battery_voltage        0               V
battery_capacity                0               %
pv1_input_power                 0               W
pv2_input_power                 0               W
pv3_input_power                 0               W
pv1_input_voltage               0               V
pv2_input_voltage               0               V
pv3_input_voltage               0               V
max_temperature                 0               °C
status_todo                     bytes.decode(raw_value)

and when run this command:

rock64@rock64:~$ mpp-solar -p /dev/hidraw0 -c QPIGS

Parameter                       Value           Unit
error                           USB open error: [Errno 2] No such file or directory: '/dev/hidraw0'

I tried every possible combination without success. My inverter is connect via usb cable. Any suggestions?

jblance commented 3 years ago

You need to determine where the inverter connection is in the Linux environment, try dmesg just after plugging the inverter cable into the Linux device to see where it gets connected

For mppsolar issues add -I to the command to get more info and post the results. The QPI or PI command is a good start to make sure you are using the correct protocol

Post the full output as it will help diagnose what is wrong (and if you are PI16 then it is probably some bugs as that protocol hasn't had much testing)

irmajavi commented 3 years ago

rock64@rock64:~$ dmesg

[    0.000000] Booting Linux on physical CPU 0x0
...snip...
[  934.302562] usb 3-1: USB disconnect, device number 2
[  934.303608] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[  934.303705] ch341 3-1:1.0: device disconnected
[  942.661469] usb 4-1: new full-speed USB device number 2 using xhci-hcd
[  942.790494] usb 4-1: New USB device found, idVendor=1a86, idProduct=7523
[  942.790527] usb 4-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[  942.790550] usb 4-1: Product: USB Serial
[  942.795399] ch341 4-1:1.0: ch341-uart converter detected
[  942.797504] usb 4-1: ch341-uart converter now attached to ttyUSB0
[ 5760.934376] usb 4-1: USB disconnect, device number 2
[ 5760.935812] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 5760.935926] ch341 4-1:1.0: device disconnected
[ 6156.977979] usb 3-1: new full-speed USB device number 3 using ohci-platform
[ 6157.182375] usb 3-1: New USB device found, idVendor=1a86, idProduct=7523
[ 6157.182392] usb 3-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 6157.182401] usb 3-1: Product: USB Serial
[ 6157.184843] ch341 3-1:1.0: ch341-uart converter detected
[ 6157.208817] usb 3-1: ch341-uart converter now attached to ttyUSB0
irmajavi commented 3 years ago

rock64@rock64:~$ mpp-solar -P PI16 -c QPI -p /dev/ttyUSB0 -I

2021-08-16 21:32:19,270:INFO:__init__:main@236: Solar Device Command Utility, version: 0.7.76, remove brackets in ved protocol
2021-08-16 21:32:19,271:INFO:__init__:main@340: Creating device "unnamed" (type: "mppsolar") on port "/dev/ttyUSB0 (porttype=None)" using protocol "PI16"
2021-08-16 21:32:19,277:INFO:device:set_port@160: Using serialio for communications
2021-08-16 21:32:19,347:INFO:__init__:main@395: Looping 1 commands
2021-08-16 21:32:19,347:INFO:__init__:main@406: Getting results from device: mppsolar device - name: unnamed, port: <mppsolar.io.serialio.SerialIO object at 0xf6430db0>, protocol: <mppsolar.protocols.pi16.pi16 object at 0xf6430d30> for command: QPI, tag: QPI, outputs: screen
2021-08-16 21:32:19,348:INFO:device:run_command@270: Running command QPI
2021-08-16 21:32:19,348:INFO:pi16:get_full_command@180: Using protocol b'PI16' with 6 commands
2021-08-16 21:32:19,349:INFO:device:run_command@296: full command b'QPI\r' for command QPI
2021-08-16 21:32:20,497:INFO:abstractprotocol:decode@175: response passed to decode: b''
2021-08-16 21:32:20,498:INFO:abstractprotocol:decode@215: Processing response of type SEQUENTIAL
2021-08-16 21:32:20,499:INFO:device:run_command@334: Decoded response {'raw_response': ['', ''], '_command': 'QPI', '_command_description': 'Device Protocol Version inquiry', 'Protocol Version': ['', '']}
2021-08-16 21:32:20,500:INFO:__init__:get_outputs@26: attempting to create output processor: screen
2021-08-16 21:32:20,509:INFO:screen:output@19: Using output processor: screen
Command: QPI - Device Protocol Version inquiry
------------------------------------------------------------
Parameter                       Value           Unit
protocol_version
jblance commented 3 years ago

So it is connected on ttyUSB0

What inverter are you using?

irmajavi commented 3 years ago

its from srne

jblance commented 3 years ago

QPI doesnt work for PI16 - try PI

jblance commented 3 years ago

srne

What model? Do you know that it supports PI16 protocol?

irmajavi commented 3 years ago

rock64@rock64:~$ mpp-solar -P PI16 -c PI -p /dev/ttyUSB0 -I

2021-08-16 21:33:16,525:INFO:__init__:main@236: Solar Device Command Utility, version: 0.7.76, remove brackets in ved protocol
2021-08-16 21:33:16,525:INFO:__init__:main@340: Creating device "unnamed" (type: "mppsolar") on port "/dev/ttyUSB0 (porttype=None)" using protocol "PI16"
2021-08-16 21:33:16,531:INFO:device:set_port@160: Using serialio for communications
2021-08-16 21:33:16,601:INFO:__init__:main@395: Looping 1 commands
2021-08-16 21:33:16,602:INFO:__init__:main@406: Getting results from device: mppsolar device - name: unnamed, port: <mppsolar.io.serialio.SerialIO object at 0xf69d4db0>, protocol: <mppsolar.protocols.pi16.pi16 object at 0xf69d4d30> for command: PI, tag: PI, outputs: screen
2021-08-16 21:33:16,602:INFO:device:run_command@270: Running command PI
2021-08-16 21:33:16,603:INFO:pi16:get_full_command@180: Using protocol b'PI16' with 6 commands
2021-08-16 21:33:16,604:INFO:abstractprotocol:get_command_defn@57: No command_defn found for PI
2021-08-16 21:33:16,604:INFO:device:run_command@296: full command b'PI\r' for command PI
2021-08-16 21:33:16,605:INFO:abstractprotocol:get_command_defn@57: No command_defn found for PI
2021-08-16 21:33:17,753:INFO:abstractprotocol:decode@175: response passed to decode: b''
2021-08-16 21:33:17,754:INFO:abstractprotocol:get_command_defn@57: No command_defn found for PI
2021-08-16 21:33:17,755:INFO:device:run_command@334: Decoded response {'raw_response': ['', ''], '_command': 'PI', 'WARNING': ["No definition for command PI in protocol b'PI16'", ''], 'response': ['', '']}
2021-08-16 21:33:17,755:INFO:__init__:get_outputs@26: attempting to create output processor: screen
2021-08-16 21:33:17,764:INFO:screen:output@19: Using output processor: screen
Command: PI - No description found
------------------------------------------------------------
Parameter                       Value           Unit
warning                         No definition for command PI in protocol b'PI16'
response
irmajavi commented 3 years ago

I tried all protocols but not response. Which one you suggest?

jblance commented 3 years ago

PI30 is the most common in use from mpp-solar activity

irmajavi commented 3 years ago

SRNE Model HF4835U80-145

irmajavi commented 3 years ago

rock64@rock64:~$ mpp-solar -P PI30 -c QPI -p /dev/ttyUSB0 -I 2021-08-16 21:40:20,039:INFO:init:main@236: Solar Device Command Utility, version: 0.7.76, remove brackets in ved protocol 2021-08-16 21:40:20,040:INFO:init:main@340: Creating device "unnamed" (type: "mppsolar") on port "/dev/ttyUSB0 (porttype=None)" using protocol "PI30" 2021-08-16 21:40:20,045:INFO:device:set_port@160: Using serialio for communications 2021-08-16 21:40:20,117:INFO:init:main@395: Looping 1 commands 2021-08-16 21:40:20,118:INFO:init:main@406: Getting results from device: mppsolar device - name: unnamed, port: <mppsolar.io.serialio.SerialIO object at 0xf6a89db0>, protocol: <mppsolar.protocols.pi30.pi30 object at 0xf6a89d30> for command: QPI, tag: QPI, outputs: screen 2021-08-16 21:40:20,118:INFO:device:run_command@270: Running command QPI 2021-08-16 21:40:20,119:INFO:abstractprotocol:get_full_command@31: Using protocol b'PI30' with 36 commands 2021-08-16 21:40:20,119:INFO:device:run_command@296: full command b'QPI\xbe\xac\r' for command QPI 2021-08-16 21:40:21,266:INFO:abstractprotocol:decode@175: response passed to decode: b'' 2021-08-16 21:40:21,267:INFO:abstractprotocol:decode@179: Response to short 2021-08-16 21:40:21,268:INFO:device:run_command@334: Decoded response {'ERROR': ['Response to short', '']} 2021-08-16 21:40:21,269:INFO:init:get_outputs@26: attempting to create output processor: screen 2021-08-16 21:40:21,277:INFO:screen:output@19: Using output processor: screen Parameter Value Unit error Response to short

jblance commented 3 years ago

doesnt look like it uses the protocols that are supported by mpp-solar so far

irmajavi commented 3 years ago

Oh really, I bought another inverter a few months ago and I use this program mpp-solar with it because is so cool and I thought it might work with this one too.

jblance commented 3 years ago

well it probably can work, we just need to find the protocol and implement it if it is not currently supported

jblance commented 3 years ago

It claims 'Supply of a variety of user-friendly communication modules, such as RS485(GPRS, WiFi, Bluetooth), CAN, USB etc., and suitable for computer, mobile phones, Internet monitoring as well as remote operations' Can you ask the supplier for the communication protocol definition?

irmajavi commented 3 years ago

Yes I can do that. If I get a response I will post it here.

jblance commented 3 years ago

you could try something like:

import serial
ser = serial.Serial('/dev/ttyUSB0', 19200, timeout=1)
print(ser)

ser.write(':010310010001EA\r\n')
print(repr(ser.read(1000)))  # Read 1000 bytes, or wait for timeout

and see what response you get

irmajavi commented 3 years ago

which program should I use to write and execute the code?

jblance commented 3 years ago

just use an editor to put it into a file like test.py and then run it with python3 test.py

On Tue, 17 Aug 2021 at 14:13, irmajavi @.***> wrote:

which program should I use to write and execute the code?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jblance/mpp-solar/issues/140#issuecomment-899940395, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJVKNS6LF5UAPCWIA5YQ43T5HAS5ANCNFSM5CIX2TGQ .

irmajavi commented 3 years ago

rock64@rock64:~/Documents$ python3 test.py Serial(port='/dev/ttyUSB0', baudrate=19200, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False, dsrdtr=False) Traceback (most recent call last): File "test.py", line 5, in ser.write(':010310010001EA\r\n') File "/usr/local/lib/python3.6/dist-packages/pyserial-3.5-py3.6.egg/serial/serialposix.py", line 616, in write d = to_bytes(data) File "/usr/local/lib/python3.6/dist-packages/pyserial-3.5-py3.6.egg/serial/serialutil.py", line 65, in to_bytes raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq)) TypeError: unicode strings are not supported, please encode to bytes: ':010310010001EA\r\n'

irmajavi commented 3 years ago

I get a response from SRNE, they send me this file:

逆控一体机modbus寄存器定义-客户版v1.3 - 中性(English).pdf

jblance commented 3 years ago

ok, well that helps the code doesnt have any modbus protocols at the moment and i dont have any modbus devices myself, so if you are interested in this in mpp-solar it will be a lot of testing on your part and will likely take a while. Are you up for that?

irmajavi commented 3 years ago

Yeah I can do that and not just me, other people can benefit from this.

pwalsh110 commented 2 years ago

I also have this HF4835U80-145 unit. Was communication with this device ever solved? So far I'm not having any luck with the USB port or my generic FTDI serial adapter in the RS485 port, but I have no documentation to go off.

irmajavi commented 2 years ago

I write my own python script and is working fine. It need improvement but it work for my needs. It is a script that send that data from the inverter to an mqtt server. This type of inverter use Modbus for communicate that is why mpp-solar is not working. If you have programming skills you can modified for your needs.

pwalsh110 commented 2 years ago

I write my own python script and is working fine. It need improvement but it work for my needs. It is a script that send that data from the inverter to an mqtt server. This type of inverter use Modbus for communicate that is why mpp-solar is not working. If you have programming skills you can modified for your needs.

Thank you that would be a very helpful start could please provide a link to your code?

irmajavi commented 2 years ago

Write me an email javier.matos@gmail.com and as soon as I can I will send it to you.

jblance commented 1 year ago

will see if @irmajavi is ok to share their code and if so and it can be added I will create an enhancement to track it