rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.71k stars 530 forks source link

PIR devices showing unavailable after upgrade to 2024.6 #1725

Open gabrielhopkins opened 3 weeks ago

gabrielhopkins commented 3 weeks ago

The problem

After upgrading HA to 2024.6, I noticed my automations based on PIR sensors weren't working. When looking at the devices through the HA interface, they showed unavailable. I reverted to 2024.5.5 and it's working again.

NB Tuya cloud has never worked well with PIR. I don't use Tinytuya

Environment

Steps to reproduce

  1. Upgrade to 2024.6
  2. Look at device in Devices

DP dump

Provide Home Assistant traceback/logs

put your log output between these markers

Additional information

jmcollin78 commented 3 weeks ago

Same here with this logs:

2024-06-08 13:15:53.764 WARNING (SyncWorker_4) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.805 WARNING (SyncWorker_3) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.810 WARNING (SyncWorker_15) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.829 WARNING (SyncWorker_16) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.856 WARNING (SyncWorker_12) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.874 WARNING (SyncWorker_17) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.881 WARNING (SyncWorker_2) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.889 WARNING (SyncWorker_18) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.894 WARNING (SyncWorker_20) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.921 WARNING (SyncWorker_0) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.943 WARNING (SyncWorker_7) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.948 WARNING (SyncWorker_22) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:53.984 WARNING (SyncWorker_6) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:54.006 WARNING (SyncWorker_13) [homeassistant.helpers.frame] 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 349: async_dispatcher_send(self._hass, signal, self._status), please report it to the author of the 'localtuya' custom integration
2024-06-08 13:15:58.881 ERROR (SyncWorker_0) [homeassistant.util.logging] Exception in _new_entity_handler when dispatching 'localtuya_entity_bfd65186b192f947cbw8wd': ('switch.commande_prises_musique',)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 261, in _new_entity_handler
    self._dispatch_status()
  File "/config/custom_components/localtuya/common.py", line 349, 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 447, in verify_event_loop_thread
    frame.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 349: async_dispatcher_send(self._hass, signal, self._status). Please report it to the author of the 'localtuya' custom integration.

Localtuya devices (light switch, movement sensor) don't work at all in my configuration.

My informations:

## System Information

version | core-2024.6.1
-- | --
installation_type | Home Assistant OS
dev | false
hassio | true
docker | true
user | root
virtualenv | false
python_version | 3.12.2
os_name | Linux
os_version | 6.6.28-haos-raspi
arch | aarch64
timezone | Europe/Paris
config_dir | /config

<details><summary>Home Assistant Community Store</summary>

GitHub API | ok
-- | --
GitHub Content | ok
GitHub Web | ok
GitHub API Calls Remaining | 5000
Installed Version | 1.34.0
Stage | running
Available Repositories | 1394
Downloaded Repositories | 46

</details>

<details><summary>Home Assistant Cloud</summary>

logged_in | false
-- | --
can_reach_cert_server | ok
can_reach_cloud_auth | ok
can_reach_cloud | ok

</details>

<details><summary>Home Assistant Supervisor</summary>

host_os | Home Assistant OS 12.3
-- | --
update_channel | stable
supervisor_version | supervisor-2024.06.0
agent_version | 1.6.0
docker_version | 25.0.5
disk_total | 457.7 GB
disk_used | 30.1 GB
healthy | true
supported | true
host_connectivity | true
supervisor_connectivity | true
ntp_synchronized | true
virtualization | 
board | rpi4-64
supervisor_api | ok
version_api | ok
installed_addons | Home Assistant Google Drive Backup (0.112.1), Samba share (12.3.1), InfluxDB (5.0.0), Glances (0.21.1), Let's Encrypt (5.0.18), NGINX Home Assistant SSL proxy (3.9.0), SQLite Web (4.1.2), AppDaemon (0.16.6), Piper (1.5.0), Whisper (2.1.0), Mosquitto broker (6.4.1), Zigbee2MQTT (1.38.0-1), Studio Code Server (5.15.0), Silicon Labs Flasher (0.2.3), Zigbee2MQTT Edge (edge), Matter Server (6.1.0), OpenThread Border Router (2.6.0)

</details>

<details><summary>Dashboards</summary>

dashboards | 8
-- | --
resources | 26
views | 45
mode | storage

</details>

<details><summary>Recorder</summary>

oldest_recorder_run | 1 juin 2024 à 07:11
-- | --
current_recorder_run | 8 juin 2024 à 13:15
estimated_db_size | 429.74 MiB
database_engine | sqlite
database_version | 3.44.2

</details>

<details><summary>Sonoff</summary>

version | 3.7.3 (e240aaf)
-- | --
cloud_online | 9 / 9
local_online | 9 / 9
debug | failed to load: 

</details>
jmcollin78 commented 3 weeks ago

A quick patch it to replace async_dispatcher_send by disptacher_send in the commons.py file of the localtuya integration. And of course import disptacher_send in line 20:

from homeassistant.helpers.dispatcher import (
    async_dispatcher_connect,
    async_dispatcher_send,
    # Add this
    dispatcher_send,
)
a1ex-ak commented 2 weeks ago

Проблема

После обновления HA до 2024.6 я заметил, что мои средства автоматизации на основе PIR-датчиков не работают. При просмотре устройств через интерфейс HA они показали недоступные. Я вернулся на 2024.5.5, и все снова работает.

Обратите внимание: облако Tuya никогда не работало с PIR. Я не использую Тинитуя

Среда

* Локальная версия: 3.6.7

* Базовая версия домашнего помощника: 2024.6.0

* [] Работает ли устройство с использованием компонента Home Assistant Tuya Cloud?

* [] Работает ли устройство с помощью инструмента командной строки Tinytuya ( [ https://github.com/jasonacox/tinytuya ](https://github.com/jasonacox/tinytuya) )?

* [] Работало ли устройство с более ранними версиями localtuya?  Который из?

* [] Используете ли вы приложение Tuya/SmartLife параллельно?

Действия по воспроизведению

1. Обновление до 2024.6

2. Посмотрите устройство в Устройствах

Дамп ДП

Предоставить отслеживание/журналы Home Assistant

put your log output between these markers

Дополнительная информация

use https://github.com/xZetsubou/hass-localtuya

r-jean-pierre commented 20 hours ago

Hi! Dont' know if is related, but this post contains the most common keywords. I got:

Exception in _new_entity_handler when dispatching 'localtuya_entity_bfbb788057e307ead732ak': ('cover.local_curtain_garden',) 
Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 261, in _new_entity_handler self._dispatch_status() 
File "/config/custom_components/localtuya/common.py", line 349, 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 349: async_dispatcher_send(self._hass, signal, self._status). 
Please report it to the author of the 'localtuya' custom integration.

I have localtuya 5.2.1 and HA core 2024.7.0b7

(also some warnings about SUPPORT_ON_OFF TEMP_CELSIUS TEMP_FAHRENHEIT CONDUCTIVITY SUPPORT_CLOSE etc.)