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

Last HA update breaks modbus? #5

Open
spjakob opened this issue Jan 18, 2025 · 4 comments
Open

Last HA update breaks modbus? #5

spjakob opened this issue Jan 18, 2025 · 4 comments

Comments

@spjakob
Copy link

spjakob commented Jan 18, 2025

I'm not really sure if this is a problem with this integration or more of a general problem, but after last update of HA it seems like this is not working anymore, and actually all other modbus services broke down as well... :(

This error originated from a custom integration.

Logger: custom_components.modbus_tcpip.coordinator
Source: helpers/update_coordinator.py:318
integration: Modbus TCP/IP (documentation, issues)
First occurred: January 15, 2025 at 08:26:37 (31488 occurrences)
Last logged: 14:23:13

Unexpected error fetching ModbusDevice: TROX130TMP data
Unexpected error fetching ModbusDevice: TROX134TMP data
Unexpected error fetching ModbusDevice: TROX132TMP data
Unexpected error fetching ModbusDevice: TROX131TMP data
Unexpected error fetching ModbusDevice: TROX133TMP data
Traceback (most recent call last):
File "/config/custom_components/modbus_tcpip/coordinator.py", line 48, in _async_setup
self._modbusDevice = device_class(self.connection_params)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/modbus_tcpip/devices/modbusdevice.py", line 20, in call
instance = super().call(*args, **kwargs)
File "/config/custom_components/modbus_tcpip/devices/Trox/TVE.py", line 22, in init
super().init(connection_params)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/modbus_tcpip/devices/modbusdevice.py", line 27, in init
self._client = ModbusTcpClient(connection_params.ip, connection_params.port)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/pymodbus/client/tcp.py", line 151, in init
host=host,
File "/usr/local/lib/python3.13/site-packages/pymodbus/client/base.py", line 191, in init
KeyError: 4196

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in __wrap_async_setup
await self._async_setup()
File "/config/custom_components/modbus_tcpip/coordinator.py", line 50, in _async_setup
raise ConfigEntryNotReady("Could not read data from device!") from err
homeassistant.exceptions.ConfigEntryNotReady: Could not read data from device!

@eriknn
Copy link
Owner

eriknn commented Jan 18, 2025

Weird, sounds like an issue with pymodbus. But it’s working on my installation. Maybe try to update required version of pymodbus in manifest.json? To version 3.8.3 which is the latest.

@spjakob
Copy link
Author

spjakob commented Jan 29, 2025

Sorry for long delay...
Seems like recent updates to HA solved problems with the generic modbus integration, but I do still have some issues.
Haven't had time to look into this, but hopefully will later.
I also like to provide some feedback on other issues/improvements soon...
I tried 3.8.3, but issue was the same...

@spjakob
Copy link
Author

spjakob commented Feb 2, 2025

I finally had som time to investigate a bit more since this integration is still not working for me (other modbus stuff is now working). I have not tried to reinstall everything, just posting here for now if you see something quickly that could be fixed. Otherwise will I try to reinstall.

This is how things looks now:

Image

and below is output from log:

KeyError: 4196

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in __wrap_async_setup
await self._async_setup()
File "/config/custom_components/modbus_tcpip/coordinator.py", line 50, in _async_setup
raise ConfigEntryNotReady("Could not read data from device!") from err
homeassistant.exceptions.ConfigEntryNotReady: Could not read data from device!
2025-02-02 09:22:11.955 ERROR (MainThread) [custom_components.modbus_tcpip.coordinator] Unexpected error fetching ModbusDevice: TS55TMP data
Traceback (most recent call last):
File "/config/custom_components/modbus_tcpip/coordinator.py", line 48, in _async_setup
self._modbusDevice = device_class(self.connection_params)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/modbus_tcpip/devices/modbusdevice.py", line 20, in call
instance = super().call(*args, **kwargs)
File "/config/custom_components/modbus_tcpip/devices/Renke/RS-WS-N01-8.py", line 18, in init
super().init(connection_params)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/modbus_tcpip/devices/modbusdevice.py", line 27, in init
self._client = ModbusTcpClient(connection_params.ip, connection_params.port)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/pymodbus/client/tcp.py", line 151, in init
retries: int = 3,
File "/usr/local/lib/python3.13/site-packages/pymodbus/client/base.py", line 191, in init
def execute(self, no_response_expected: bool, request: ModbusPDU) -> ModbusPDU:

@eriknn
Copy link
Owner

eriknn commented Feb 6, 2025

I can't understand what's wrong here.
This seems to be the key line, from modbusdevice.py:
self._client = ModbusTcpClient(connection_params.ip, connection_params.port)
which initializes the Modbus Device / connection with the pymodbus library.
Of course, you could put some debugging before that line to verify the ip and port, but I can't understand why that'd be wrong.
Or why all devices would crash like this. Maybe the number of devices is the problem.

Are you able to read the devices from any other modbus-application? Are they all connected through a gateway of some sorts?

Edit:
Maybe we should try with this instead, this is better / the correct way to do it anyways:
self._client = ModbusTcpClient(host=connection_params.ip, port=connection_params.port)

Updated online files now (no new release yet)

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

2 participants