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

async_dispatcher_send from a thread other than the event loop exception #1872

Open
kozfelipe opened this issue Dec 21, 2024 · 5 comments
Open
Labels
bug Something isn't working

Comments

@kozfelipe
Copy link

v5.2.1

2024-12-20 22:42:15.037 ERROR (SyncWorker_10) [homeassistant.util.logging] Exception in _new_entity_handler when dispatching 'localtuya_entity_eb07899373d1128bb9abtc': ('light.lampada_escritorio',)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 263, in _new_entity_handler
    self._dispatch_status()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/config/custom_components/localtuya/common.py", line 351, in _dispatch_status
    async_dispatcher_send(self._hass, signal, self._status)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/dispatcher.py", line 214, in async_dispatcher_send
    hass.verify_event_loop_thread("async_dispatcher_send")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  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>...
    )
RuntimeError: Detected that custom integration 'localtuya' calls async_dispatcher_send 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/#async_dispatcher_send at custom_components/localtuya/common.py, line 351: async_dispatcher_send(self._hass, signal, self._status). Please report it to the author of the 'localtuya' custom integration
{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.12.5",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.13.0",
    "docker": true,
    "arch": "aarch64",
    "timezone": "America/Sao_Paulo",
    "os_name": "Linux",
    "os_version": "6.6.62-haos-raspi",
    "supervisor": "2024.12.0",
    "host_os": "Home Assistant OS 14.1",
    "docker_version": "27.2.0",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "version": "2.0.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "localtuya": {
      "documentation": "https://github.com/rospogrigio/localtuya/",
      "version": "5.2.1",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "localtuya",
    "name": "LocalTuya integration",
    "codeowners": [
      "rospogrigio",
      "postlund"
    ],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/rospogrigio/localtuya/",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/rospogrigio/localtuya/issues",
    "requirements": [],
    "version": "5.2.1",
    "is_built_in": false,
    "overwrites_built_in": false
  },
  "data": {
    "device_config": {
      "friendly_name": "L\u00e2mpada Escrit\u00f3rio",
      "protocol_version": "3.3",
      "entities": [
        {
          "friendly_name": "L\u00e2mpada Escrit\u00f3rio",
          "brightness": 22,
          "color_temp": 23,
          "brightness_lower": 10,
          "brightness_upper": 1000,
          "color_mode": 21,
          "color": 24,
          "color_temp_min_kelvin": 2700,
          "color_temp_max_kelvin": 6500,
          "color_temp_reverse": false,
          "scene": 26,
          "music_mode": false,
          "id": 20,
          "platform": "light"
        }
      ],
    },
  }
}
@kozfelipe kozfelipe added the bug Something isn't working label Dec 21, 2024
@nathan815
Copy link

I am seeing this error as well. Also, my LocalTuya devices are flapping between available and unavailable.

@sant1ago
Copy link

I am seeing the same issue today as well

@kozfelipe
Copy link
Author

yeah, my device is flapping too since some recent update

@kozfelipe
Copy link
Author

kozfelipe commented Dec 27, 2024

Hey guys, it turns out this project is dead and no longer maintained. The solution I found was to remove this repo /devices and port it to this fork https://github.com/xZetsubou/hass-localtuya

@kozfelipe kozfelipe reopened this Dec 27, 2024
@kozfelipe
Copy link
Author

kozfelipe commented Jan 14, 2025

#1791
#1751
#1762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants