gpulido / homeassistant-selve

Home Assistant Custom component to manage Selve devices
MIT License
3 stars 3 forks source link

HomeAssistant Core crashing at random intervals, following I/O Error 5 [cannot open serial port] #2

Closed fss closed 3 years ago

fss commented 3 years ago

I'm getting HA Core freezes occasionally, it's still not 100% confirmed but my blind guess is Selve connector unfortunately. Every single time my HA crashes I'm first seeing I/O Error 5 [cannot open serial port] followed by a MQTT client error and then my HA core becomes completely unresponsive.

Unfortunately, I don't get anything else in the logs and it's happening completely random

gpulido commented 3 years ago

Hello. The selve component is not using mqtt. Please activate the debug logs for the component and provide any log to take a look. I've been using the selve component without issues for the last 3 years. (I have iveo). However I've planned to refurbish the component to use integration workflows and more "ha" official look. No ETA yet.

fss commented 3 years ago

@gpulido yeah, ofc I know Selve connector has nothing to do with MQTT :) it's just a coincidence the MQTT error gets logged right after I/O Error 5

do you access your dongle using /dev/ttyUSB[x] or /dev/serial/by-id/xxx symlink?

gpulido commented 3 years ago

Right now I'm using the symlink as hassio keep changing the tty assigned on every update of the core :)

fss commented 3 years ago

OK, and possibly lame question: how do I enable debug logging on that component?

gpulido commented 3 years ago

Take a look here https://www.home-assistant.io/integrations/logger/

Btw, you at least should have a log showing any error, haven't you?

fss commented 3 years ago

it's always the same sequence before HA goes unresponsive:

2021-04-01 23:57:31 ERROR (SyncWorker_2) [selve] error open serial port: [Errno 5] I/O error
2021-04-01 23:57:37 ERROR (Thread-5) [paho.mqtt.client] Caught exception in on_message: Event loop is closed
2021-04-01 23:57:37 ERROR (Thread-5) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3452, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1779, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1181, in loop
    rc = self.loop_read(max_packets)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1572, in loop_read
    rc = self._packet_read()
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2310, in _packet_read
    rc = self._packet_handle()
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle
    return self._handle_publish()
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish
    self._handle_on_message(message)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message
    self.on_message(self, self._userdata, message)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 850, in _mqtt_on_message
    self.hass.add_job(self._mqtt_handle_message, msg)
  File "/usr/src/homeassistant/homeassistant/core.py", line 338, in add_job
    self.loop.call_soon_threadsafe(self.async_add_job, target, *args)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 764, in call_soon_threadsafe
    self._check_closed()
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
fss commented 3 years ago

@gpulido I might have a possible breakthrough 🙈

my Selve USB-RF stick is (was until this morning) connected via USB extension cable. this is my latest suspect, as I unplugged the dongle the HA crash immediately happened.

not sure if it's your module then or the Python-Selve dependency?

fss commented 3 years ago

seems it's either this integration or python-selve crashing and giving this untraceable I/O Error 5 which crashes the whole HA core.

I removed the integration completely and moved to Node-RED where I'm directly writing to serial port and it's now stable for 3 days straight (previously I wasn't able to beat 2 days)