rospogrigio / localtuya

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

Unable to add devices #591

Open stefan-west1 opened 2 years ago

stefan-west1 commented 2 years ago

The problem

Trying to add a new device via the UI. Doesn't automatically detect any devices. Add ... and manuallly input information. Get response "An unknown error occurred. See log for details."

Environment

Steps to reproduce

  1. Add locatuya to integrations via UI
  2. Add device manually

Provide Home Assistant taceback/logs

2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Started heartbeat loop 2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Sending command heartbeat (device type: type_0a) 2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Send payload: b'{}' 2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Waiting for sequence number -100 2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Sending command status (device type: type_0a) 2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Send payload: b'{"gwId":"30070740bcddc26917f7","devId":"30070740bcddc26917f7"}' 2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Waiting for sequence number 1 2021-10-13 11:57:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Connection lost: [Errno 104] Connection reset by peer 2021-10-13 11:57:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Heartbeat failed due to timeout, disconnecting 2021-10-13 11:57:07 ERROR (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Failed to get status: Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 510, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 472, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 451, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 240, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError 2021-10-13 11:57:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [300...7f7] Closing connection 2021-10-13 11:57:07 ERROR (MainThread) [custom_components.localtuya.config_flow] Unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 279, in async_step_basic_info self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 192, in validate_input detected_dps = await interface.detect_available_dps() File "/config/custom_components/localtuya/pytuya/init.py", line 510, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 472, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 451, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 240, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

logger.set_level custom_components.localtuya: debug

-->

Additional information

mvroosmalen1970 commented 2 years ago

I've solved this using tuya-cli: tuya-cli set --id IDIDIDID --key KEYKEYKEY --ip 192.168.1.XXX --protocol-version 3.3 --dps 1 --set 0. While running tuya-cli in terminal, I completed add the new device in tuyalocal. Maybe this is a solution for you