joleys / niko-home-control-II

Home Assistant Custom Integration for Niko Home Control II
MIT License
75 stars 20 forks source link

Runtime error: async_update_device called from a thread #139

Closed ubipo closed 6 months ago

ubipo commented 6 months ago

HA core: 2024.5.0 nhc2: v4.0.2

Logger: root
Source: helpers/frame.py:203
First occurred: 10:27:24 PM (1 occurrences)
Last logged: 10:27:24 PM

Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
    rc = self._loop(timeout)
         ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1164, in _loop
    rc = self.loop_read()
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1556, in loop_read
    rc = self._packet_read()
         ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
    rc = self._packet_handle()
         ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle
    return self._handle_publish()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3330, in _handle_publish
    self._handle_on_message(message)
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message
    on_message(self, self._userdata, message)
  File "/config/custom_components/nhc2/nhccoco/coco.py", line 123, in _on_message
    self._system_info_callback(self._system_info)
  File "/config/custom_components/nhc2/__init__.py", line 96, in process_sysinfo
    dev_reg.async_get_or_create(
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 758, in async_get_or_create
    device = self.async_update_device(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 907, in async_update_device
    self.hass.verify_event_loop_thread("async_update_device")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'nhc2' calls async_update_device from a thread at custom_components/nhc2/__init__.py, line 96: dev_reg.async_get_or_create(. Please report it to the author of the 'nhc2' custom integration.

Related to #136 / #137 . Fixed by #140 .