rospogrigio / localtuya

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

ERROR: Failed to set DPs #850

Open findel opened 2 years ago

findel commented 2 years ago

The problem

I have some automations that gradually change bulb colours and/or brightness. I had to change from using the cloud API to localtuya because they send too many API calls.

But since switching to localtuya I regularly get "Failed to set DPs" errors (see log example below). I know that the DP number and value are valid as I can use localtuya.set_dp to run the same change without an error.

Any idea what is causing this? Or how to fix it?

Environment

Steps to reproduce

  1. Have an automation that makes small changes to bulbs every few seconds.
  2. Run it.
  3. See errors.

Configuration configuration.yaml or config_flow

Here is the config for one of the affected bulbs:

- friendly_name: Bedside Lamp
  device_id: [REMOVED]
  local_key: [REMOVED]
  host: [REMOVED]
  protocol_version: "3.3"
  entities:
    - platform: light
      friendly_name: Bedside Lamp
      id: 20
      color_mode: 21 
      brightness: 22 
      color_temp: 23 
      color: 24
      brightness_lower: 10 
      brightness_upper: 1000 
      scene: 25 

Provide Home Assistant taceback/logs

2022-06-07 12:44:41 ERROR (MainThread) [custom_components.localtuya.common] [236...d5f] Failed to set DPs {24: '001e03e8027f', 21: 'colour'}
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/common.py", line 221, in set_dps
    await self._interface.set_dps(states)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 522, in set_dps
    return await self.exchange(SET, dps)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 460, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 247, 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
swests commented 1 year ago

Seeing the same exception.

2022-12-23 08:16:50.196 ERROR (MainThread) [custom_components.localtuya.common] [620...145] Failed to set DPs {1: True}
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/common.py", line 332, in set_dps
await self._interface.set_dps(states)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 557, in set_dps
return await self.exchange(SET, dps)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 486, in exchange
msg = await self.dispatcher.wait_for(seqno)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 259, 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