make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.07k stars 435 forks source link

Reload Config Entry Makes device unavailable #1937

Closed ChrisPotDev closed 1 month ago

ChrisPotDev commented 1 month ago

Home Assistant Core 2024.5.4 Supervisor 2024.05.1 Operating System 12.3

Describe the bug I have 1 or 2 tuya plugs that seem to go unavailable from time to time, theres no consistant reason. Reloading the config for tuya local used to solve the issue.

Ive recently noticed it no longer works.

Reloading the integration using any of my available devices makes that device unavailable.

Example service: homeassistant.reload_config_entry data: {} target: entity_id: switch.tuya_server_plug

To Reproduce Run the above service for any of my Tuya smart plugs

Expected behavior Reload the integration

Additional context Some of the errors found in the error log

Logger: homeassistant.config_entries Source: config_entries.py:772 First occurred: 8:44:27 PM (1 occurrences) Last logged: 8:44:27 PM

Error unloading entry bneta_server_plug for tuya_local Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 772, in async_unload result = await component.async_unload_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tuya_local/init.py", line 517, in async_unload_entry await async_delete_device(hass, config) File "/config/custom_components/tuya_local/device.py", line 655, in async_delete_device await hass.data[DOMAIN][device_id]["device"].async_stop() File "/config/custom_components/tuya_local/device.py", line 170, in async_stop await self._refresh_task TypeError: object Future can't be used in 'await' expression

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:910 integration: Sensor (documentation, issues) First occurred: 8:44:27 PM (1 occurrences) Last logged: 8:44:27 PM

Error while removing entity sensor.bneta_server_plug_voltage Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1378, in async_remove await self.__async_remove_impl(force_remove) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1394, in __async_remove_impl await self.async_will_remove_from_hass() File "/config/custom_components/tuya_local/helpers/mixin.py", line 111, in async_will_remove_from_hass await self._device.async_unregister_entity(self) File "/config/custom_components/tuya_local/device.py", line 195, in async_unregister_entity await self.async_stop() File "/config/custom_components/tuya_local/device.py", line 170, in async_stop await self._refresh_task TypeError: object Future can't be used in 'await' expression

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 910, in async_reset await entity.async_remove() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1383, in async_remove self.__remove_future.set_result(None) asyncio.exceptions.InvalidStateError: invalid state

Logger: homeassistant.components.select Source: helpers/entity_platform.py:910 integration: Select First occurred: 8:33:45 PM (1 occurrences) Last logged: 8:33:45 PM

Error while removing entity select.bneta_server_plug_initial_state Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1378, in async_remove await self.__async_remove_impl(force_remove) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1394, in __async_remove_impl await self.async_will_remove_from_hass() File "/config/custom_components/tuya_local/helpers/mixin.py", line 111, in async_will_remove_from_hass await self._device.async_unregister_entity(self) File "/config/custom_components/tuya_local/device.py", line 195, in async_unregister_entity await self.async_stop() File "/config/custom_components/tuya_local/device.py", line 170, in async_stop await self._refresh_task TypeError: object Future can't be used in 'await' expression

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 910, in async_reset await entity.async_remove() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1383, in async_remove self.__remove_future.set_result(None) asyncio.exceptions.InvalidStateError: invalid state

Logger: homeassistant.config_entries Source: config_entries.py:772 First occurred: 8:33:45 PM (1 occurrences) Last logged: 8:33:45 PM

Error unloading entry bneta_server_plug for tuya_local Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 772, in async_unload result = await component.async_unload_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tuya_local/init.py", line 517, in async_unload_entry await async_delete_device(hass, config) File "/config/custom_components/tuya_local/device.py", line 655, in async_delete_device await hass.data[DOMAIN][device_id]["device"].async_stop() File "/config/custom_components/tuya_local/device.py", line 170, in async_stop await self._refresh_task TypeError: object Future can't be used in 'await' expression

This error originated from a custom integration.

Logger: custom_components.localtuya.common Source: custom_components/localtuya/pytuya/init.py:255 integration: LocalTuya First occurred: 8:31:28 PM (4 occurrences) Last logged: 8:34:27 PM

Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:1934 First occurred: 8:44:41 PM (2 occurrences) Last logged: 8:46:05 PM

websocket_api script: Error executing script. Error for call_service at pos 1: The config entry bneta_server_plug (tuya_local) with entry_id 3b48e90316b026e147dfd852944a6ab1 cannot be unloaded because it is not in a recoverable state (ConfigEntryState.FAILED_UNLOAD)

Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/connection.py:307 integration: Home Assistant WebSocket API First occurred: 8:44:41 PM (2 occurrences) Last logged: 8:46:05 PM

[140387825490624] Error handling message: The config entry bneta_server_plug (tuya_local) with entry_id 3b48e90316b026e147dfd852944a6ab1 cannot be unloaded because it is not in a recoverable state (ConfigEntryState.FAILED_UNLOAD) (home_assistant_error) Chris from 192.168.10.10 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36)

make-all commented 1 month ago

Duplicate of #1888