olivergregorius / sun2000_modbus

Library for reading Huawei Sun2000 inverter metrics via Modbus TCP
MIT License
23 stars 9 forks source link

Error on test #22

Closed MilanCiprian closed 1 year ago

MilanCiprian commented 1 year ago

I install sun2000_modbus

> pip3 install sun2000_modbus
Collecting sun2000_modbus
  Using cached sun2000_modbus-1.1.1-py3-none-any.whl (11 kB)
Collecting pymodbus==2.5.3
  Using cached pymodbus-2.5.3-py2.py3-none-any.whl (154 kB)
Collecting pyserial>=3.4
  Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
Requirement already satisfied: six>=1.15.0 in /usr/lib/python3/dist-packages (from pymodbus==2.5.3->sun2000_modbus) (1.16.0)
Installing collected packages: pyserial, pymodbus, sun2000-modbus
Successfully installed pymodbus-2.5.3 pyserial-3.5 sun2000-modbus-1.1.1

Then I create the file ReadPower.py with code:

from sun2000_modbus import inverter
from sun2000_modbus import registers

inverter = inverter.Sun2000(host='192.168.15.40')
inverter.connect()
if inverter.connected:
    input_power = inverter.read_formatted(registers.InverterEquipmentRegister.InputPower)
    print(input_power)

And I get this error:

> python3 ReadPower.py
Traceback (most recent call last):
  File "/var/www/html/PFV_Sun2000/ReadPower.py", line 1, in <module>
    from sun2000_modbus import inverter
  File "/usr/local/lib/python3.9/dist-packages/sun2000_modbus/inverter.py", line 7, in <module>
    from . import datatypes
  File "/usr/local/lib/python3.9/dist-packages/sun2000_modbus/datatypes.py", line 32
    match data_type:
          ^
SyntaxError: invalid syntax
MilanCiprian commented 1 year ago

Install python3.10