joleys / niko-home-control-II

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

Runtime error in HA 2024.05 #136

Closed blatruwe closed 6 months ago

blatruwe commented 6 months ago

When upgrading to HA 2024.05, the nhc2 integration does not work anymore, the following is displayed in the log (currently running 4.0.1):

2024-05-01 21:47:09.621 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Connected to MQTT broker
2024-05-01 21:47:09.681 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2] systeminfo.published: NhcVersion: 2.19.1.608 - CocoImage 2023.3-20240228182619
2024-05-01 21:47:09.683 WARNING (Thread-3 (_thread_main)) [homeassistant.helpers.frame] Detected that custom integration 'nhc2' calls async_create_task from a thread at custom_components/nhc2/__init__.py, line 109: hass.async_create_task(, please report it to the author of the 'nhc2' custom integration
2024-05-01 21:47:09.683 ERROR (Thread-3 (_thread_main)) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/opt/python/3.12.2/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/opt/python/3.12.2/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
    rc = self._loop(timeout)
         ^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 1164, in _loop
    rc = self.loop_read()
         ^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 1556, in loop_read
    rc = self._packet_read()
         ^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
    rc = self._packet_handle()
         ^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle
    return self._handle_publish()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 3330, in _handle_publish
    self._handle_on_message(message)
  File "/srv/homeassistant/lib/python3.12/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message
    on_message(self, self._userdata, message)
  File "/home/homeassistant/.homeassistant/custom_components/nhc2/nhccoco/coco.py", line 123, in _on_message
    self._system_info_callback(self._system_info)
  File "/home/homeassistant/.homeassistant/custom_components/nhc2/__init__.py", line 109, in process_sysinfo
    hass.async_create_task(
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/core.py", line 816, in async_create_task
    self.verify_event_loop_thread("async_create_task")
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'nhc2' calls async_create_task from a thread at custom_components/nhc2/__init__.py, line 109: hass.async_create_task(. Please report it to the author of the 'nhc2' custom integration.
2024-05-01 21:47:09.686 WARNING (Thread-3 (_thread_main)) [py.warnings] /opt/python/3.12.2/lib/python3.12/threading.py:1075: RuntimeWarning: coroutine 'ConfigEntries.async_forward_entry_setup' was never awaited
  self._invoke_excepthook(self)
p8ulus commented 6 months ago

I have the same problems after updating Homeassistant

JonasReviers commented 6 months ago

Same problem, with the same faults in the log. Downgrading to 2024.4.4 solved the problem for now.

janvand commented 6 months ago

Same here!

BramDeBock commented 6 months ago

Same here :-(

bartsmetdv commented 6 months ago

Same issue here

Handy-Harry commented 6 months ago

Here also

SeBsZ commented 6 months ago

Me too, I also downgraded to 2024.4.4 using the terminal add-on with command ha core update --version 2024.4.4 and I'm back in business for now.

tijsverkoyen commented 6 months ago

Would any of you be able to verify if https://github.com/joleys/niko-home-control-II/pull/137 work? I don't have access to my local Niko installation at this moment, but I think this change should fix the issue

joleys commented 6 months ago

@tijsverkoyen: working on it!

joleys commented 6 months ago

That seems to be the right fix.

tijsverkoyen commented 6 months ago

I have released https://github.com/joleys/niko-home-control-II/releases/tag/v4.0.2

bvm02 commented 6 months ago

Would any of you be able to verify if #137 work? I don't have access to my local Niko installation at this moment, but I think this change should fix the issue

Works for me! Thanks

blatruwe commented 6 months ago

It seems to work after using the new code. Thanks for this quick fix!

Handy-Harry commented 6 months ago

It's working again! Thanks a lot

JonasReviers commented 6 months ago

Works great! @tijsverkoyen thanks for your quick action and effort! Where can we buy a coffee for you?

tijsverkoyen commented 6 months ago

Works great! @tijsverkoyen thanks for your quick action and effort! Where can we buy a coffee for you?

No problem. No pressure, and certainly not obligation at all. But you can by me a coffee at https://github.com/sponsors/tijsverkoyen