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

'hass_agent' calls device_registry.async_update_device from a thread ..... #54

Open
ThomasCr opened this issue Oct 3, 2024 · 4 comments

Comments

@ThomasCr
Copy link

ThomasCr commented Oct 3, 2024

I noticed the following error message in the logfiles:

Detected that custom integration 'hass_agent' calls device_registry.async_update_device from a thread other than the event loop, which may cause Home Assistant to crash or data to corrupt. For more information, see https://developers.home-assistant.io/docs/asyncio_thread_safety/#device_registryasync_update_device at custom_components/hass_agent/init.py, line 29: device_registry.async_get_or_create(. Please report it to the author of the 'hass_agent' custom integration.

2024-10-03 13:23:55.974 ERROR (SyncWorker_12) [homeassistant.util.logging] Exception in updated when handling msg on 'hass.agent/devices/PCT': '{"serial_number":"7705d518-a4f9-4e2d-9b39-eb26d6272e1e","device":{"identifiers":"hass.agent-PCT","manufacturer":"LAB02 Research","model":"Microsoft Windows NT 10.0.19045.0","name":"PCT","sw_version":"2022.14.0"},"apis":{"notifications":true,"media_player":false}}'

    _report_integration(what, integration_frame, level, error_if_integration)

    raise RuntimeError(

RuntimeError: Detected that custom integration 'hass_agent' calls device_registry.async_update_device from a thread other than the event loop, which may cause Home Assistant to crash or data to corrupt. For more information, see https://developers.home-assistant.io/docs/asyncio_thread_safety/#device_registryasync_update_device at custom_components/hass_agent/__init__.py, line 29: device_registry.async_get_or_create(. Please report it to the author of the 'hass_agent' custom integration.
@a-maggi
Copy link

a-maggi commented Dec 8, 2024

Same issue. This is my complete log

RuntimeError: Detected that custom integration 'hass_agent' calls device_registry.async_update_device from a thread other than the event loop, which may cause Home Assistant to crash or data to corrupt. For more information, see https://developers.home-assistant.io/docs/asyncio_thread_safety/#device_registryasync_update_device at custom_components/hass_agent/__init__.py, line 29: device_registry.async_get_or_create(. Please report it to the author of the 'hass_agent' custom integration
2024-12-08 01:31:24.995 WARNING (SyncWorker_10) [homeassistant.helpers.frame] Detected that custom integration 'hass_agent' calls device_registry.async_update_device from a thread other than the event loop, which may cause Home Assistant to crash or data to corrupt. For more information, see https://developers.home-assistant.io/docs/asyncio_thread_safety/#device_registryasync_update_device at custom_components/hass_agent/__init__.py, line 29: device_registry.async_get_or_create(. Please report it to the author of the 'hass_agent' custom integration
2024-12-08 01:31:25.004 ERROR (SyncWorker_10) [homeassistant.util.logging] Exception in updated when handling msg on 'hass.agent/devices/MINI-GALAXY': '{"serial_number":"33975f83-eea1-4485-befc-bc4c9878696b","device":{"identifiers":"hass.agent-MINI-GALAXY","manufacturer":"LAB02 Research","model":"Microsoft Windows NT 10.0.22631.0","name":"MINI-GALAXY","sw_version":"2022.14.0"},"apis":{"notifications":true,"media_player":true}}'
Traceback (most recent call last):
  File "/config/custom_components/hass_agent/__init__.py", line 144, in updated
    update_device_info(hass, entry, payload)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_agent/__init__.py", line 29, in update_device_info
    device_registry.async_get_or_create(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        config_entry_id=entry.entry_id,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
        sw_version=new_device_info["device"]["sw_version"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 829, in async_get_or_create
    device = self.async_update_device(
        device.id,
    ...<16 lines>...
        via_device_id=via_device_id,
    )
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1044, in async_update_device
    self.hass.verify_event_loop_thread("device_registry.async_update_device")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 474, in verify_event_loop_thread
    frame.report_non_thread_safe_operation(what)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 368, in report_non_thread_safe_operation
    report(
    ~~~~~~^
        f"calls {what} from a thread other than the event loop, "
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
        error_if_integration=True,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 164, in report
    report_usage(
    ~~~~~~~~~~~~^
        what,
        ^^^^^
    ...<4 lines>...
        level=level,
        ^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 242, in report_usage
    _report_integration_frame(
    ~~~~~~~~~~~~~~~~~~~~~~~~~^
        what,
        ^^^^^
    ...<3 lines>...
        integration_behavior is ReportBehavior.ERROR,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 340, in _report_integration_frame
    raise RuntimeError(
    ...<5 lines>...
    )

@devangapatel
Copy link

I am having the same issue. 100s of instances of the same error clogging up the HA logs.

@sammyke007
Copy link

Any news?

@devangapatel
Copy link

Is anyone actively working on this project?

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

4 participants