Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError (pymodbus error) #55

Open
pavalenta opened this issue Dec 20, 2024 · 4 comments
Open

ModuleNotFoundError (pymodbus error) #55

pavalenta opened this issue Dec 20, 2024 · 4 comments

Comments

@pavalenta
Copy link

Using Home Assistant via Docker with core version just updated to 2025.1.0.dev202412200230 and getting the following on start up.

Logger: homeassistant.setup
Source: setup.py:334
First occurred: 10:49:36 PM (1 occurrences)
Last logged: 10:49:36 PM

Setup failed for custom integration 'solark_modbus': Unable to import component: No module named 'pymodbus.register_read_message'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component
component = await integration.async_get_component()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1034, in async_get_component
self._component_future.result()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1014, in async_get_component
comp = await self.hass.async_add_import_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self._get_component, True
^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/loader.py", line 1074, in _get_component
ComponentProtocol, importlib.import_module(self.pkg_path)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
return func(*args, **kwargs)
File "/usr/local/lib/python3.13/importlib/init.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 1026, in exec_module
File "", line 488, in _call_with_frames_removed
File "/config/custom_components/solark_modbus/init.py", line 12, in
from .hub import SolArkModbusHub
File "/config/custom_components/solark_modbus/hub.py", line 12, in
from pymodbus.register_read_message import ReadHoldingRegistersResponse
ModuleNotFoundError: No module named 'pymodbus.register_read_message'

@blassond
Copy link

blassond commented Jan 4, 2025

The following worked for me as far as pulling in DATA again, but logs indicate that it will not work on later releases.
Seems like HA updated their version of python and we will need to wait for this integration to do the same.

Temp Fix:
edit config\custom_components\solark_modbus\hub.py

Original Line 12 ------------
from pymodbus.register_read_message import ReadHoldingRegistersResponse
Updated Line 12 -------------
from pymodbus.pdu.register_read_message import ReadHoldingRegistersResponse

Original Line 64 ------------
self._client = ModbusSerialClient(method='rtu',port=parsed.path.rstrip('/')+parsed.netloc,baudrate=9600,
Updated Line 64 -----------
self._client = ModbusSerialClient(port=parsed.path.rstrip('/')+parsed.netloc,baudrate=9600,

@pbix
Copy link
Owner

pbix commented Jan 7, 2025

I did some investigating and found that there is once again a breaking change in pymodbus as of v3.4.7 which is now the default in HA 2025.1. As a result this integration is now broken. Would love to see a pull request which properly resolves this issue but if I do not I will try and get some time reserved to fix it.

In the meantime I can only advise people to refrain from upgrading to any 2025 release until a reasonable solution can be found.

@pbix pbix mentioned this issue Jan 7, 2025
@pbix pbix changed the title ModuleNotFoundError ModuleNotFoundError (pymodbus error) Jan 7, 2025
poldim added a commit to poldim/HA-solark-PV that referenced this issue Jan 10, 2025
Per pbix#55 (comment), PR to implement these changes
@poldim
Copy link
Contributor

poldim commented Jan 10, 2025

The following worked for me as far as pulling in DATA again, but logs indicate that it will not work on later releases. Seems like HA updated their version of python and we will need to wait for this integration to do the same.

Temp Fix: edit config\custom_components\solark_modbus\hub.py

Original Line 12 ------------ from pymodbus.register_read_message import ReadHoldingRegistersResponse Updated Line 12 ------------- from pymodbus.pdu.register_read_message import ReadHoldingRegistersResponse

Original Line 64 ------------ self._client = ModbusSerialClient(method='rtu',port=parsed.path.rstrip('/')+parsed.netloc,baudrate=9600, Updated Line 64 ----------- self._client = ModbusSerialClient(port=parsed.path.rstrip('/')+parsed.netloc,baudrate=9600,

thanks, this did solve the issue

@poldim
Copy link
Contributor

poldim commented Jan 10, 2025

I did some investigating and found that there is once again a breaking change in pymodbus as of v3.4.7 which is now the default in HA 2025.1. As a result this integration is now broken. Would love to see a pull request which properly resolves this issue but if I do not I will try and get some time reserved to fix it.

In the meantime I can only advise people to refrain from upgrading to any 2025 release until a reasonable solution can be found.

I created #57 to implement @blassond's changes. Testing this worked for me on 2015.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants