localtuya icon indicating copy to clipboard operation
localtuya copied to clipboard

Unknown error when adding Bluetooth Gateway via config flow

Open chris24walsh opened this issue 2 years ago • 53 comments

The problem

When attempting to add a Tuya Bluetooth Gateway via the config flow, it gives me an error: An unknown error occurred. See log for details.

Checking the logs gives this more detailed error message:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, 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.10/asyncio/tasks.py", line 456, in wait_for
    return 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 428, in async_step_basic_sub_device_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 260, in validate_input
    detected_dps = await interface.detect_available_dps(data[CONF_DEVICE_ID])
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 684, in detect_available_dps
    status = await self.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 598, in status
    status = await self.exchange(ACTION_STATUS, cid=cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 563, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 325, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

Environment

  • Localtuya version: b0d5fec76b48b51bcbf1f61f282ff87ccd641228
  • Last working localtuya version (if known and relevant):
  • Home Assistant Core version: 2023.1.2
  • [x] Are you using the Home Assistant Tuya Cloud component ?
  • [x] Are you using the Tuya App in parallel ?

Steps to reproduce

  1. Add Integration -> LocalTuya
  2. Select gateway from list of devices.
  3. Fill in details, checking the 'Is gateway' box.
  4. Click 'SUBMIT'
  5. Error appears in the top of the dialog box, An unknown error occurred. See log for details.

Configuration configuration.yaml or config_flow

Name: Bluetooth Gateway
Local key: <redacted>
Host: 192.168.2.134
Device ID: bf12b9e35267857daeyjrf
Protocol version: 3.3 (Also tried 3.1)
Is Gateway: (checked box)

DP dump

INFO:localtuya:Detecting list of available DPS of device bf12b9e35267857daeyjrf [192.168.2.134], protocol 3.3. DEBUG:localtuya.pytuya:[bf1...jrf] Sending command 10 (device type: type_0a) DEBUG:localtuya.pytuya:[bf1...jrf] Sending payload: b'{"gwId":"bf12b9e35267857daeyjrf","devId":"bf12b9e35267857daeyjrf","uid":"bf12b9e35267857daeyjrf","t":"1673454033"}' DEBUG:localtuya.pytuya:[bf1...jrf] Command 10 waiting for sequence number 1 DEBUG:localtuya.pytuya:[bf1...jrf] Connection lost: [Errno 54] Connection reset by peer ERROR:localtuya.pytuya:[bf1...jrf] Failed to get status: Traceback (most recent call last): File "/Users/chris/.pyenv/versions/3.9.6/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 "/Users/chris/.pyenv/versions/3.9.6/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 "/Users/chris/dev/personal/hass/local-tuya/tuyadebug/localtuya/pytuya/init.py", line 849, in detect_available_dps data = await self.status() File "/Users/chris/dev/personal/hass/local-tuya/tuyadebug/localtuya/pytuya/init.py", line 781, in status status = await self.exchange(DP_QUERY) File "/Users/chris/dev/personal/hass/local-tuya/tuyadebug/localtuya/pytuya/init.py", line 755, in exchange msg = await self.dispatcher.wait_for(seqno, payload.cmd) File "/Users/chris/dev/personal/hass/local-tuya/tuyadebug/localtuya/pytuya/init.py", line 446, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/Users/chris/.pyenv/versions/3.9.6/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

Provide Home Assistant taceback/logs

This error originated from a custom integration.

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:325
Integration: LocalTuya (documentation, issues)
First occurred: 4:24:14 PM (1 occurrences)
Last logged: 4:24:14 PM

[bf1...jrf] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, 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.10/asyncio/tasks.py", line 456, in wait_for
    return 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 702, in detect_available_dps
    status = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 602, in status
    status = await self.exchange(ACTION_STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 563, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 325, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
This error originated from a custom integration.

Logger: custom_components.localtuya.config_flow
Source: custom_components/localtuya/pytuya/__init__.py:325
Integration: LocalTuya (documentation, issues)
First occurred: 4:24:14 PM (1 occurrences)
Last logged: 4:24:14 PM

Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, 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.10/asyncio/tasks.py", line 456, in wait_for
    return 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 364, in async_step_basic_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 270, in validate_input
    detected_dps = await interface.detect_available_dps()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 702, in detect_available_dps
    status = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 602, in status
    status = await self.exchange(ACTION_STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 563, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 325, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

Additional information

Adding this device via the configuration.yaml 'works', but the adding the subdevices doesn't seem to work. I believe this issue may be due to the only sub-devices being bluetooth smart locks, as I understand that a lock entity is not yet defined for localtuya. Can you confirm this, or explain what else I can do here?

chris24walsh avatar Jan 11 '23 16:01 chris24walsh