rospogrigio / localtuya

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

Appears as unavailable after restarting Home Assistant #1751

Open reprogerman opened 1 month ago

reprogerman commented 1 month ago

After restarting home assistant the devices appear as unavailable, curiously if the device in question goes to the Tuya integration in which it appears as available and you turn it on and off then it appears in your local location. I don't know why it is, but it happens to me quite frequently. Any solution ? I have everything updated, integration, Home assistant etc.

zztopgtb commented 1 month ago

Yeah I see this also. When HA is rebooted localtuya devices are unavailable. If I then turn a switch on either physically or via tuya cloud app, the entities are then updated and usable in HA.

martinw72 commented 1 month ago

Do you get any log entries, guys?

dominiclesinski commented 1 month ago

Just have seen the same behavior after a power outage.

Logs are: Logger: custom_components.localtuya.cover Source: custom_components/localtuya/pytuya/init.py:255 integration: LocalTuya [bfb...9pt] Entity cover.rollladen_arbeitszimmer is requesting unknown DPS index 1

possibly related: Logger: homeassistant.util.logging Source: util/logging.py:95 First occurred: 8:59:47 PM (6 occurrences) Last logged: 9:05:59 PM

Exception in _update_handler when dispatching 'localtuya_bf2b2e3cd504166f40hai9': ({'2': 'forward', '3': 30},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 411, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 195, in status_updated if self._state.isupper(): ^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'isupper' Exception in _update_handler when dispatching 'localtuya_bf2414657b282f1e9dxrrl': ({'2': 'forward', '3': 25},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 411, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 195, in status_updated if self._state.isupper(): ^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'isupper' Exception in _update_handler when dispatching 'localtuya_bff202f72c171a189cl03f': ({'2': 'forward', '3': 25},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 411, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 195, in status_updated if self._state.isupper(): ^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'isupper'

After using smart life app for any input entities returned to correct states.

npa-homeassistant commented 1 month ago

I was just about to come here to mention this too. It's been this way for months. After every HA restart, I have to remember to reload the LocalTuya integration and this fixes it (yes, I know I could automate that, but it seems to be papering over the cracks).

Once reloaded, things seem fine, but it is required every time.

martinw72 commented 1 month ago

Moved to xZetsubou fork. Some interesting new options and a lot of issues solved! Would make sense to merch this two.

B-double-U commented 1 month ago

Same here. After reloading the integration after a reboot, it works again.

Here is my log entry, just FYI in case it helps:

Exception in _new_entity_handler when dispatching 'localtuyaentity[redacted]': ('switch.woox_smartplug',) 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.

reprogerman commented 1 month ago

It never allows me to reload the integration, come on... when I hit reload it asks me to restart home assistant and a yellow contour line appears on the integration.

AlainPeccable commented 3 weeks ago

Same here but only with 2 valves (seen as switches). All lights entities are working fine.

After each restart I go to Configure ==> Edit ==> select the valves ==> and just save it. They are reloaded and working fine until next restart.

This is from this morning restart:

Enregistreur: homeassistant.util.logging Source: util/logging.py:95 S'est produit pour la première fois: 06:44:05 (2 occurrences) Dernier enregistrement: 06:44:05

Exception in _new_entity_handler when dispatching 'localtuya_entity_bf72a6cd05deab1b9asm7n': ('switch.valve_eau_de_pluie',) 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. Exception in _new_entity_handler when dispatching 'localtuya_entity_bf26b675b9db9e1626nt5v': ('switch.eau_de_ville',) 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.

orgrazm commented 2 days ago

Novice here so sorry if this is out of place, but I'm having this issue as well. Looking at the logs I'm seeing, this issue seems similar to #1761 which has a pull request #1762 waiting on testing if someone here has the skills...

sushant-here commented 15 hours ago

Having this issue with my curtain motors. Moving them once with Tuya app seems to fix. Not sure when it stopped working.

How can I test the fix?… https://github.com/rospogrigio/localtuya/pull/1762