mkfam7 / solaxx3

Module to work with Solax X3 solar inverters
MIT License
3 stars 0 forks source link

in _unsigned16 return self._input_registers_values_list[addr] #6

Closed JorgeGoncalves1 closed 8 months ago

JorgeGoncalves1 commented 8 months ago

I'm getting this error. can you help?

Traceback (most recent call last): File "/home/pi/programacao/working/ler_rs485.py", line 15, in inverter_ac_power = s.read("grid_power")[0] ^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 143, in read value = self.read_register(register_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 130, in read_register val = self._read_register(register_info["register_type"], register_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 82, in _read_register val = self._unsigned16(register_type, register_info["address"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 47, in _unsigned16 return self._input_registers_values_list[addr]


IndexError: list index out of range
mkfam7 commented 8 months ago

Hello Jorge,

Could you please send me the code you are running that produces that error so that I can try to reproduce it on my side? Also, but inverter model do you use and what firmware version?

JorgeGoncalves1 commented 8 months ago

Hello,

Thanks for your reply.

I don't know how to check the firmware version, if you could help me I would appreciate it.

But the X3-MIC/PRO-G2 10KW inverter was purchased and installed last week, so it must have the latest version..

I tried using the software on two inverters (X3-MIC/PRO-G2 10KW and X1-Boost/Air/Mini 5KW) and got the same error.

Here is the software and the message obtained.

I hope you can help me resolve it.

Thanks Jorge

THE PROGRAM

from solaxx3.rs485 import SolaxX3

adjust the serial port and baud rate as necessary

s = SolaxX3(port="/dev/ttyUSB0", baudrate=9600)

if s.connect(): s.read_all_registers()

available_stats = s.list_register_names()
for stat in available_stats:
    print(stat)

# battery_temperature = s.read("temperature_battery")[0]
# print(f"\n\nBattery temperature: {s.read('temperature_battery')[0]}")
inverter_ac_power = s.read("grid_power")[0]
etoday_togrid = s.read("energy_to_grid_today")[0]
print(inverter_ac_power,etoday_togrid)

else: print("Cannot connect to the Modbus Server/Slave") exit()

RUNNING THE PROGRAM:

(energy_diverter) @.***:~/programacao/working $ python ler_rs485.py grid_voltage grid_current grid_power pv_voltage_1 pv_voltage_2 pv_current_1 pv_current_2 grid_frequency radiator_temperature run_mode power_dc1 power_dc2 temperature_fault_value pv1_volt_fault_value pv2_volt_fault_value gfci_fault_value grid_fault_value grid_freqfaultvalue_t dci_fault_value time_count_down battery_voltage_charge_1 battery_current_charge_1 battery_power_charge1 bms_connect_state temperature_battery bdc_status grid_status mppt_count battery_capacity output_energy_charge output_energy_charge_today input_energy_charge input_energy_charge_today bms_charge_max_current bms_discharge_max_current power_to_ev ref_power_to_ev pcs_major_fault battery_major_fault inv_fault_message mgr_fault_message bat_bms_fault_message feed_in_power energy_to_grid_meter energy_from_grid_meter off_grid_voltage off_grid_current off_grid_power off_grid_frequency energy_to_grid_today energy_to_grid_total lock_state bus_volt w_dcv_fault_val w_overload_fault_val w_battery_volt_fault_val grid_voltage_r grid_current_r grid_power_r grid_frequency_r grid_voltage_s grid_current_s grid_power_s grid_frequency_s grid_voltage_t grid_current_t grid_power_t grid_frequency_t off_grid_volt_r off_grid_current_r off_grid_power_active_r off_grid_power_s_r off-grid-volt-s off_grid_current_s off_grid_power_active_s off_grid_power_s_s off_grid_volt_t off_grid_current_t off_grid_power_active_t off_grid_power_s_t feedin_power_r_phase feedin_power_s_phase feedin_power_t_phase ongrid_run_time offgrid_run_time offgrid_yield_total offgrid_yield_today echarge_today echarge_total solar_energy_total solar_energy_today feed_in_energy_today consumption_energy_today inv_volt_r inv_volt_s inv_volt_t feedin_power_meter_2 feedin_energy_total_meter_2 consum_energy_total_meter_2 feedin_energy_today_meter_2 consum_energy_today_meter_2 feedin_power_r_phase_meter_2 feedin_power_s_phase_meter_2 feedin_power_t_phase_meter_2 meter_1_communication_state meter_2_communication_state battery_tem_high battery_tem_low cell_voltage_high cell_voltage_low bms_user_soc bms_user_soh grid_reactive_power_total_meter grid_reactive_power_r_meter grid_reactive_power_s_meter grid_reactive_power_t_meter grid_power_factor_total_meter grid_power_factor_r_meter grid_power_factor_s_meter grid_power_factor_t_meter grid_frequency_meter grid_voltage_total_meter grid_voltage_r_meter grid_voltage_s_meter grid_voltage_t_meter grid_current_total_meter grid_current_r_meter grid_current_s_meter grid_current_t_meter modbus_power_control target_finish_tag active_power_target w_reactive_power_target w_active_power_real w_reactive_power_real w_active_power_upper w_active_power_lower w_reactive_power_upper w_reactive_power_lower target_energy charge_discharge_power chargeable_electric_capacity dischargeable_electric_capacity time_of_duration target_soc soc_upper soc_lower remote_control_timeout w_battery_force_charge_flag w_bms_relay_state serial_number firmware_version_dsp hardware_version_dsp firmware_version_modbus_rtu firmware_version_arm firmware_version_arm_bootloader rtc_datetime registration_code inverter_power_type user_password advanced_password machine_type Traceback (most recent call last): File "/home/pi/programacao/working/ler_rs485.py", line 15, in inverter_ac_power = s.read("grid_power")[0] ^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 143, in read value = self.read_register(register_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 130, in read_register val = self._read_register(register_info["register_type"], register_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 82, in _read_register val = self._unsigned16(register_type, register_info["address"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 47, in _unsigned16 return self._input_registers_values_list[addr]


IndexError: list index out of range
(energy_diverter) ***@***.***:~/programacao/working $ 

> No dia 26/02/2024, às 07:10, mkfam7 ***@***.***> escreveu:
> 
> 
> Hello Jorge,
> 
> Could you please send me the code you are running that produces that error so that I can try to reproduce it on my side?
> Also, but inverter model do you use and what firmware version?
> 
> —
> Reply to this email directly, view it on GitHub <https://github.com/mkfam7/solaxx3/issues/6#issuecomment-1963451068>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQK7YCRMVYTBQHEVR34YCY3YVQYPVAVCNFSM6AAAAABDZCUGROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTGQ2TCMBWHA>.
> You are receiving this because you authored the thread.
> 
JorgeGoncalves1 commented 8 months ago

I Also tried

The ORIGINAL PROGRAM JUST CHANGE THE BAUD RATE TO 9600

from solaxx3.rs485 import SolaxX3

adjust the serial port and baud rate as necessary

s = SolaxX3(port="/dev/ttyUSB0", baudrate=9600)

if s.connect(): s.read_all_registers()

available_stats = s.list_register_names()
for stat in available_stats:
    print(stat)

battery_temperature = s.read("temperature_battery")
print(f"\n\nBattery temperature: {s.read('temperature_battery')}")

else: print("Cannot connect to the Modbus Server/Slave") exit()

I GET...

(energy_diverter) @.***:~/programacao/working $ python ler_rs485.py grid_voltage grid_current grid_power pv_voltage_1 pv_voltage_2 pv_current_1 pv_current_2 grid_frequency radiator_temperature run_mode power_dc1 power_dc2 temperature_fault_value pv1_volt_fault_value pv2_volt_fault_value gfci_fault_value grid_fault_value grid_freqfaultvalue_t dci_fault_value time_count_down battery_voltage_charge_1 battery_current_charge_1 battery_power_charge1 bms_connect_state temperature_battery bdc_status grid_status mppt_count battery_capacity output_energy_charge output_energy_charge_today input_energy_charge input_energy_charge_today bms_charge_max_current bms_discharge_max_current power_to_ev ref_power_to_ev pcs_major_fault battery_major_fault inv_fault_message mgr_fault_message bat_bms_fault_message feed_in_power energy_to_grid_meter energy_from_grid_meter off_grid_voltage off_grid_current off_grid_power off_grid_frequency energy_to_grid_today energy_to_grid_total lock_state bus_volt w_dcv_fault_val w_overload_fault_val w_battery_volt_fault_val grid_voltage_r grid_current_r grid_power_r grid_frequency_r grid_voltage_s grid_current_s grid_power_s grid_frequency_s grid_voltage_t grid_current_t grid_power_t grid_frequency_t off_grid_volt_r off_grid_current_r off_grid_power_active_r off_grid_power_s_r off-grid-volt-s off_grid_current_s off_grid_power_active_s off_grid_power_s_s off_grid_volt_t off_grid_current_t off_grid_power_active_t off_grid_power_s_t feedin_power_r_phase feedin_power_s_phase feedin_power_t_phase ongrid_run_time offgrid_run_time offgrid_yield_total offgrid_yield_today echarge_today echarge_total solar_energy_total solar_energy_today feed_in_energy_today consumption_energy_today inv_volt_r inv_volt_s inv_volt_t feedin_power_meter_2 feedin_energy_total_meter_2 consum_energy_total_meter_2 feedin_energy_today_meter_2 consum_energy_today_meter_2 feedin_power_r_phase_meter_2 feedin_power_s_phase_meter_2 feedin_power_t_phase_meter_2 meter_1_communication_state meter_2_communication_state battery_tem_high battery_tem_low cell_voltage_high cell_voltage_low bms_user_soc bms_user_soh grid_reactive_power_total_meter grid_reactive_power_r_meter grid_reactive_power_s_meter grid_reactive_power_t_meter grid_power_factor_total_meter grid_power_factor_r_meter grid_power_factor_s_meter grid_power_factor_t_meter grid_frequency_meter grid_voltage_total_meter grid_voltage_r_meter grid_voltage_s_meter grid_voltage_t_meter grid_current_total_meter grid_current_r_meter grid_current_s_meter grid_current_t_meter modbus_power_control target_finish_tag active_power_target w_reactive_power_target w_active_power_real w_reactive_power_real w_active_power_upper w_active_power_lower w_reactive_power_upper w_reactive_power_lower target_energy charge_discharge_power chargeable_electric_capacity dischargeable_electric_capacity time_of_duration target_soc soc_upper soc_lower remote_control_timeout w_battery_force_charge_flag w_bms_relay_state serial_number firmware_version_dsp hardware_version_dsp firmware_version_modbus_rtu firmware_version_arm firmware_version_arm_bootloader rtc_datetime registration_code inverter_power_type user_password advanced_password machine_type Traceback (most recent call last): File "/home/pi/programacao/working/ler_rs485.py", line 13, in battery_temperature = s.read("temperature_battery") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 143, in read value = self.read_register(register_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 130, in read_register val = self._read_register(register_info["register_type"], register_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 82, in _read_register val = self._unsigned16(register_type, register_info["address"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/energy_diverter/lib/python3.11/site-packages/solaxx3/rs485.py", line 47, in _unsigned16 return self._input_registers_values_list[addr]


IndexError: list index out of range
(energy_diverter) ***@***.***:~/programacao/working $ 

> No dia 26/02/2024, às 07:10, mkfam7 ***@***.***> escreveu:
> 
> 
> Hello Jorge,
> 
> Could you please send me the code you are running that produces that error so that I can try to reproduce it on my side?
> Also, but inverter model do you use and what firmware version?
> 
> —
> Reply to this email directly, view it on GitHub <https://github.com/mkfam7/solaxx3/issues/6#issuecomment-1963451068>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQK7YCRMVYTBQHEVR34YCY3YVQYPVAVCNFSM6AAAAABDZCUGROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTGQ2TCMBWHA>.
> You are receiving this because you authored the thread.
> 
mkfam7 commented 8 months ago

Hello Jorge,

This is how I get the firmware version from my inverter: From the display of the inverter I navigate to the following paths:

After doing some tests on my side, I suppose the error you get is because the program does not see any register at address "2" (which is kind of weird). Please send me the firmware information and also try with the following requirements package versions: pymodbus==3.6.3 pyserial==3.5

Also please run the following program and send me the output (it should display 2 lists with all registers):

from solaxx3.rs485 import SolaxX3

# adjust the serial port and baud rate as necessary
s = SolaxX3(port="/dev/ttyUSB0", baudrate=115200)

if s.connect():
    s.read_all_registers()

    print(f"Input registers: {s._input_registers_values_list}")
    print(f"Holding registers: {s._holding_registers_values_list}")

else:
    print("Cannot connect to the Modbus Server/Slave")
    exit()
JorgeGoncalves1 commented 8 months ago

Hello,

FirmWare is:

"ver":"2.035.01","type":4,”Data"

PROGRAM RESULT

(venv) @.:~/programacao/working $ pip list | grep pyserial pyserial 3.5 pyserial-asyncio 0.6 (venv) @.:~/programacao/working $ pip list | grep pymodbus pymodbus 3.6.3 (venv) @.:~/programacao/working $ python test1.py Input registers: [] Holding registers: [] (venv) @.:~/programacao/working $

Regards

Jorge

No dia 28/02/2024, às 09:23, mkfam7 @.***> escreveu:

Hello Jorge,

This is how I get the firmware version from my inverter: From the display of the inverter I navigate to the following paths:

About -> Inverter -> DSP About -> Inverter -> ARM After doing some tests on my side, I suppose the error you get is because the program does not see any register at address "2" (which is kind of weird). Please send me the firmware information and also try with the following requirements package versions: pymodbus==3.6.3 pyserial==3.5

Also please run the following program and send me the output (it should display 2 lists with all registers):

from solaxx3.rs485 import SolaxX3

adjust the serial port and baud rate as necessary

s = SolaxX3(port="/dev/ttyUSB0", baudrate=115200)

if s.connect(): s.read_all_registers()

print(f"Input registers: {s._input_registers_values_list}")
print(f"Holding registers: {s._holding_registers_values_list}")

else: print("Cannot connect to the Modbus Server/Slave") exit() — Reply to this email directly, view it on GitHub https://github.com/mkfam7/solaxx3/issues/6#issuecomment-1968559546, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQK7YCXEHZIMPDWY232XGK3YV3ZQTAVCNFSM6AAAAABDZCUGROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGU2TSNJUGY. You are receiving this because you authored the thread.

mkfam7 commented 8 months ago

Hello Jorge,

It looks like the program does not see any memory location in your inverter's registers, so you get an error because of that. Please contact the Solax support and ask them about how to configure your inverter to be read from a program via RS485 RTU.

Sorry I could not help.