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' called from a thread other than the event loop #1761

Open
1 of 4 tasks
fabio-garavini opened this issue Aug 15, 2024 · 0 comments · May be fixed by #1762
Open
1 of 4 tasks

'async_dispatcher_send' called from a thread other than the event loop #1761

fabio-garavini opened this issue Aug 15, 2024 · 0 comments · May be fixed by #1762
Labels
bug Something isn't working

Comments

@fabio-garavini
Copy link

The problem

Error during status update of some generic smart plugs (i don't know which brand or model they are).
The switch becomes randomly unavailable for long periods of time.

Environment

  • Localtuya version: latest from master branch (5.2.1)

  • Home Assistant Core version: 2024.8.1

  • Does the device work using the Home Assistant Tuya Cloud component ?

  • Does the device work using the Tinytuya (https://github.com/jasonacox/tinytuya) command line tool ?

  • Was the device working with earlier versions of localtuya ? Which one?

  • Are you using the Tuya/SmartLife App in parallel ?

  • Home Assistant running on: Raspberry Pi 4 (8GB)

Steps to reproduce

DP dump

Provide Home Assistant traceback/logs

2024-08-15 12:20:31.873 ERROR (SyncWorker_7) [homeassistant.util.logging] Exception in _new_entity_handler when dispatching 'localtuya_entity_<device_id>': ('switch.frigorifero_cantina',)
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 463, in verify_event_loop_thread
    frame.report_non_thread_safe_operation(what)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 225, in report_non_thread_safe_operation
    report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 159, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 197, in _report_integration
    raise RuntimeError(
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.

2024-08-15 12:20:31.879 ERROR (SyncWorker_4) [homeassistant.util.logging] Exception in _new_entity_handler when dispatching 'localtuya_entity_<device2_id>: ('switch.freezer_cantina',)
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 463, in verify_event_loop_thread
    frame.report_non_thread_safe_operation(what)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 225, in report_non_thread_safe_operation
    report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 159, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 197, in _report_integration
    raise RuntimeError(
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.

Additional information

@fabio-garavini fabio-garavini added the bug Something isn't working label Aug 15, 2024
@fabio-garavini fabio-garavini linked a pull request Aug 15, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant