rospogrigio / localtuya

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

Connection to device succeeded but no datapoints found #1730

Open CodeFatherG opened 3 weeks ago

CodeFatherG commented 3 weeks ago

The problem

Trying to add the 2 devices of FLG0153HA. Device is not discovered and even getting keys from tuya-cli doesn't add the device.

image

config_entry-localtuya-02211510b02b7a27ffcc3a4deaecf621.json

Environment

Steps to reproduce

  1. Add device to smart life
  2. setup tuya cloud
  3. use tuya-cli to get keys
  4. attempt to add device

DP dump

Provide Home Assistant traceback/logs

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/localtuya/discovery.py:67
integration: LocalTuya (documentation, issues)
First occurred: 9:31:24 PM (270 occurrences)
Last logged: 9:42:44 PM

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/discovery.py", line 65, in datagram_received
    data = decrypt_udp(data)
           ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/discovery.py", line 30, in decrypt_udp
    return _unpad(decryptor.update(message) + decryptor.finalize()).decode()
                                              ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 184, in finalize
    data = self._ctx.finalize()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 223, in finalize
    raise ValueError(
ValueError: The length of the provided data is not a multiple of the block length.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1238, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/config/custom_components/localtuya/discovery.py", line 67, in datagram_received
    data = data.decode()
           ^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 1: invalid continuation byte

Additional information

ehran commented 2 weeks ago

Having similar issues, I tried adding a wifi energy meter, integrated but unable to find DPs, and then another device (water valve) crashed and I am unable to add it back (its getting added but then shows offline whereas in the Tuya app and integration it works well) Any issue with localtuya's latest version ?

Siffup commented 2 weeks ago

Same over here with 2 temp/hum devices.

Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:863

[bf7...afw] Failed to get status: Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut ^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/locks.py", line 386, in acquire await fut 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 863, in detect_available_dps data = await self.status() ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 795, in status status = await self.exchange(DP_QUERY) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 769, in exchange msg = await self.dispatcher.wait_for(seqno, payload.cmd) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 450, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for async with timeouts.timeout(timeout): File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in aexit raise TimeoutError from exc_val TimeoutError

neildsb commented 1 week ago

try https://github.com/xZetsubou/hass-localtuya

ehran commented 1 week ago

@neildsb is that a different version of localtuya than the one on HACS ?

neildsb commented 1 week ago

@neildsb is that a different version of localtuya than the one on HACS ?

it's a fork, and works

see https://github.com/xZetsubou/hass-localtuya/discussions/79

ehran commented 1 week ago

thanks, will try :)

ehran commented 1 week ago

@neildsb I installed the fork following the instructions, all my devices seem to be recognized so all is well. I then proceeded to add the energy meter, I see that there is a new protocol (3.5) available however after trying different options (3.4, 3.5, manual DPs etc..) I am still getting the error message "Connection to device succeeded but no datapoints could be found. Please try set-up again. If problem persists, create a new issue (including debug logs)."

Any hints ? :'(

Thanks !

Pico1965 commented 1 week ago

Same here with QS-WIFI-SEC02 switch:

`2024-06-19 16:03:09.544 ERROR (MainThread) [custom_components.localtuya.pytuya] [bf0...ls6] Failed to get status: Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut ^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/locks.py", line 386, in acquire await fut 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 863, in detect_available_dps data = await self.status() ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 795, in status status = await self.exchange(DP_QUERY) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 769, in exchange msg = await self.dispatcher.wait_for(seqno, payload.cmd) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/pytuya/init.py", line 450, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for async with timeouts.timeout(timeout): File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in aexit raise TimeoutError from exc_val TimeoutError 2024-06-19 16:03:09.582 DEBUG (MainThread) [custom_components.localtuya.config_flow] Initial state update failed (), trying reset command 2024-06-19 16:03:09.583 DEBUG (MainThread) [custom_components.localtuya.config_flow] No DPS able to be detected: object of type 'NoneType' has no len() 2024-06-19 16:03:09.583 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {} 2024-06-19 16:03:13.444 INFO (MainThread) [custom_components.localtuya.common] [bf6...l6l] Trying to connect to 192.168.0.228... 2024-06-19 16:03:13.799 ERROR (MainThread) [custom_components.localtuya.common] [bf6...l6l] Initial state update failed, giving up: DecodeError('could not decrypt data: wrong local_key? (exception: Expecting value: line 1 column 1 (char 0))') 2024-06-19 16:03:13.803 WARNING (MainThread) [custom_components.localtuya.common] [bf6...l6l] Disconnected - waiting for discovery broadcast 2024-06-19 16:03:18.450 INFO (MainThread) [custom_components.localtuya.common] [bf6...l6l] Trying to connect to 192.168.0.228... 2024-06-19 16:03:18.718 ERROR (MainThread) [custom_components.localtuya.common] [bf6...l6l] Initial state update failed, giving up: DecodeError('could not decrypt data: wrong local_key? (exception: Expecting value: line 1 column 1 (char 0))') 2024-06-19 16:03:18.721 WARNING (MainThread) [custom_components.localtuya.common] [bf6...l6l] Disconnected - waiting for discovery broadcast`

Thanks