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

Appears as unavailable after restarting Home Assistant #1751

Open
reprogerman opened this issue Jul 21, 2024 · 14 comments
Open

Appears as unavailable after restarting Home Assistant #1751

reprogerman opened this issue Jul 21, 2024 · 14 comments
Labels
bug Something isn't working

Comments

@reprogerman
Copy link

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.

@reprogerman reprogerman added the bug Something isn't working label Jul 21, 2024
@zztopgtb
Copy link

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
Copy link

Do you get any log entries, guys?

@dominiclesinski
Copy link

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
Copy link

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
Copy link

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

@B-double-U
Copy link

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 'localtuya_entity[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
Copy link
Author

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
Copy link

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
Copy link

orgrazm commented Sep 5, 2024

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
Copy link

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?… #1762

@fabio-garavini
Copy link

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?… #1762

You have to backup the localtuya folder which is in your custom_components folder and replace it with the one you can find in my repo.
Restart HA

@orgrazm
Copy link

orgrazm commented Sep 7, 2024

I have applied the changes to common.py in #1762 and it does indeed resolve this issue along with #1761. Thank you @fabio-garavini!

@fablav76
Copy link

fablav76 commented Sep 9, 2024

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

Exactly my problem. At every restart of HA many devices are unaivalable. Manually restarting the integration solved the problem.
@fabio-garavini how to solve?

@fabio-garavini
Copy link

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?… #1762

You have to backup the localtuya folder which is in your custom_components folder and replace it with the one you can find in my repo.
Restart HA

Try this @fablav76

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