wills106 / homeassistant-solax-modbus

SolaX Power Modbus custom_component for Home Assistant (Supports some AlphaESS, Growatt, Sofar, Solinteg, Solis, SRNE, Swatten)
317 stars 101 forks source link

Custom integration won't load with 2023.9 & 2023.9.1 #528

Closed jamespreedy closed 1 year ago

jamespreedy commented 1 year ago

Describe the bug The integration worked fine immediately after 2023.9 was released on Wednesday. On Thursday I noticed that my Solax device went dead and all my entities went unavailable. Rebooting the host brought it back to life. 2023.9.1 came out yesterday and the integration now won't load at all.

Screenshot 2023-09-10 at 8 56 57 am

Screenshot 2023-09-10 at 8 57 04 am

Mandatory details

  1. Integration Version: 2023.9.3
  2. HA Version: 2023.9.1
  3. Inverter Brand: SolaX
  4. Plugin Used: SolaX
  5. First 6 digits of Serial: H34A10
  6. Connection Method: Waveshare RS485 to Eth

Detailed Error Log

Logger: homeassistant.setup
Source: loader.py:826 
First occurred: 5:56:58 am (1 occurrences) 
Last logged: 5:56:58 am

Setup failed for custom integration solax_modbus: Unable to import component: Exception importing custom_components.solax_modbus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 818, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/solax_modbus/__init__.py", line 31, in <module>
    from pymodbus.payload import BinaryPayloadBuilder, BinaryPayloadDecoder, Endian
  File "/usr/local/lib/python3.11/site-packages/pymodbus/payload.py", line 28, in <module>
    class BinaryPayloadBuilder:
  File "/usr/local/lib/python3.11/site-packages/pymodbus/payload.py", line 42, in BinaryPayloadBuilder
    self, payload=None, byteorder=Endian.Little, wordorder=Endian.Big, repack=False
                                  ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 784, in __getattr__
    raise AttributeError(name) from None
AttributeError: Little

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 215, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 826, in get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.solax_modbus

Additional context This custom component has been flawless since setting it up. Nothing I'm aware of has changed from a physical install perspective, and the Waveshare still has the blue connected light on it.

I believe there were a bunch of Modbus changes to HA 2023.9?

I also have a Nilan MVHR which also connects via Modbus (same Waveshare RS485 to Eth) - the custom integration for this also went dead following the 2023.9 HA update.

Appreciate this might be broken on the HA side, but just wanted to make sure I was reporting it. If there is any further information I can get for you to help resolve this, please let me know. 🍺

wills106 commented 1 year ago

Just released 2023.09.4b4 with the missing Endian.BIG from plugin_sofar and plugin_solax_a1j1

wartungsmonteur commented 1 year ago

Das nenne ich Super Service, also dann spendiert alle mal dem guten Menschen auch ein paar Kaffee.

https://ko-fi.com/wills106

Grüße und Danke

uspino2 commented 1 year ago

Keep getting these errors with 4b4:

unrecognized Growatt_Modbus inverter type - firmware version : unknown
10:34:33 – (ERROR) SolaX Inverter Modbus (custom integration)
Growatt_Modbus: cannot find firmware version, even not for other Inverter
10:34:33 – (ERROR) SolaX Inverter Modbus (custom integration)
Growatt_Modbus: reading firmware number from address 0xbb9 failed; other address may succeed
10:34:33 – (WARNING) SolaX Inverter Modbus (custom integration)
Growatt_Modbus: reading firmware number from address 0x9 failed; other address may succeed
10:34:28 – (WARNING) SolaX Inverter Modbus (custom integration)

Reverting back to 2023.09.3 works for me (after a couple of reboots)

wills106 commented 1 year ago

How are you connecting? PocketWiFi, RS485-USB or RS485-Ethernet?

uspino2 commented 1 year ago

WaveShare RS485 TCP

jamespreedy commented 1 year ago

Das nenne ich Super Service, also dann spendiert alle mal dem guten Menschen auch ein paar Kaffee.

https://ko-fi.com/wills106

Grüße und Danke

Thanks for sharing ... beer money sent! 🍺

Matz88 commented 1 year ago

Just released 2023.09.4b4 with the missing Endian.BIG from plugin_sofar and plugin_solax_a1j1

Perfect! Working like a charme

wills106 commented 1 year ago

Just released 2023.09.4b5 with further code cleanup.

jamespreedy commented 1 year ago

@wills106 - issues resolved, I'm back up an running! Thank you SO MUCH for all your help again. 🍺

uspino2 commented 1 year ago

For those of us who couldn't make 4b4 work, what would be the best installation process to get everything in the right order and pyModbus in the right version?

wills106 commented 1 year ago

For those of us who couldn't make 4b4 work

b5 should work for you now, it's been tested on a Waveshare setup.

mudshurko commented 1 year ago

I'm sorry updated all to the latest b5 HA2023.9.2 with USB serial restarted incl coldstart 2 x Solax X3 Hybrid G4 Master-Slave get this

Cleanup recv buffer before send: 0xaa 0x55 0xf 0xc8 0xff 0x1 0x1 0................

Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for solax_modbus doing blocking calls at custom_components/solax_modbus/init.py, line 336: return self._client.read_holding_registers(address, count, **kwargs)

unrecognized inverter type - serial number : unknown

SolaX: cannot find serial number, even not for MIC

SolaX: reading serial number from address 0x300 failed; other address may succeed

Cleanup recv buffer before send: 0x60 0xea 0x0 0x0 0x0 0x4e 0x60 .........

SolaX: reading serial number from address 0x0 failed; other address may succeed

mudshurko commented 1 year ago

hi tried now to install pymodbus with pip install -U pymodbus but pip list will not list it after reboot any recommendation how to run pymodbus?

infradom commented 1 year ago

hi tried now to install pymodbus with pip install -U pymodbus but pip list will not list it after reboot any recommendation how to run pymodbus?

I dont believe installing pymodbus manually is the way to go, especially since b5, we fixed the required version. A hard restart of the HA hardware sometimes helps You seem to have two inversters on the same modbus. I have no experience with the Master-Slave concept. Which modbus addresses are used by both inverters ?

wills106 commented 1 year ago

custom_components/solax_modbus/init.py, line 336: return self._client.read_holding_registers(address, count, **kwargs)

Even though you have downloaded 2023.09.4b5 you actually have 2023.09.4b4 code loaded there. In 2023.09.4b5 than line of code is now at line 344

Remove the Integration from the Integration page and reconfigure it, it then should load the 2023.09.4b5 code.

uspino2 commented 1 year ago

Working perfectly with 2023.09.04. For those wanting to check HA pyModbus version in a VM environment, go to the console, then:

ha > login
# docker exec -it homeassistant /bin/bash
pip show pymodbus

As always, thank you so much @wills106

infradom commented 1 year ago

Working perfectly with 2023.09.04. For those wanting to check HA pyModbus version in a VM environment, go to the console, then:

ha > login
# docker exec -it homeassistant /bin/bash
pip show pymodbus

As always, thank you so much @wills106

Thanks for this usefull instruction, I always forget how to execute commands in another container

wills106 commented 1 year ago

Working perfectly with 2023.09.04. For those wanting to check HA pyModbus version

Thanks I have updated the Readme with the Info.

I'm going to close this issue down now as it seems to be resolved.