Open majo551 opened 8 months ago
I have created a Pull-request which should fix this issue: https://github.com/tahvane1/jablotron80/pull/174
It seems to be the resault of unhandled exceptions during the reconnection (jablotron.py:888). By adding an if statement for host is unreachable and connection refused
except serial.SerialException as ex: if "timed out" in f'{ex}': LOGGER.info('Timeout, retrying') elif "Connection refused" in f'{ex}': LOGGER.info('Connection refused by remote serial host, retrying') elif "unreachable" in f'{ex}': LOGGER.info('Remote serial host is currently unreachable, retrying')
has fixed my issues.
I connect to JA via Serial2Net socket connection. However when there is a network update/reboot or temporary disconnection (i.g. maintenance ) and the connection is interrupted the HA integration fails with unhandled exception. As a result the connection never restarts and the integration is dead (first issue) but all sensors /integration keeps showing as available and working (second bug)
Attached is the error log from HA: `This error originated from a custom integration.
Logger: custom_components.jablotron80 Source: custom_components/jablotron80/jablotron.py:750 Integration: Jablotron 80 (documentation, issues) First occurred: March 3, 2024 at 14:52:55 (1 occurrences) Last logged: March 3, 2024 at 14:52:55
Unexpected error: %s Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/serial/urlhandler/protocol_socket.py", line 63, in open self._socket = socket.create_connection(self.from_url(self.portstr), timeout=POLL_TIMEOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/socket.py", line 852, in create_connection raise exceptions[0] File "/usr/local/lib/python3.12/socket.py", line 837, in create_connection sock.connect(sa) OSError: [Errno 113] Host is unreachable
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/config/custom_components/jablotron80/jablotron.py", line 750, in read_send_packet_loop records = self._read_data() ^^^^^^^^^^^^^^^^^ File "/config/custom_components/jablotron80/jablotron.py", line 900, in _read_data self.reconnect() File "/config/custom_components/jablotron80/jablotron.py", line 695, in reconnect self.connect() File "/config/custom_components/jablotron80/jablotron.py", line 880, in connect self._connection = serial.serial_for_url(url=self._device, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/serial/init.py", line 90, in serial_for_url instance.open() File "/usr/local/lib/python3.12/site-packages/serial/urlhandler/protocol_socket.py", line 66, in open raise SerialException("Could not open port {}: {}".format(self.portstr, msg)) serial.serialutil.SerialException: Could not open port socket://10.xxxx:2600: [Errno 113] Host is unreachable `
The integration keeps showing as available:
I found out only by looking at the RF history:
I simulated this behavior few times, all the time python code crashes and never recovers /retry to connect again until HA reboot.