rospogrigio / localtuya

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

Unable to add new device - Auto-discovery not working; and "No datapoints found" #1664

Open icornish72 opened 4 months ago

icornish72 commented 4 months ago

Adding a new device - no Automatic discovery, but when I manually enter the data and submit, I get the error "No datapoints"

Environment

Steps to reproduce

1.

DP dump

Provide Home Assistant traceback/logs

[home-assistant_localtuya_2024-02-08T16-18-43.281Z.log](https://github.com/rospogrigio/localtuya/files/14211968/home-assistant_localtuya_2024-02-08T16-18-43.281Z.log)

Additional information

Bebebe1974 commented 4 months ago

Adding a new device - Automatic discovery find device, but I get the error "No datapoints"

Localtuya version: 5.9.0 Home Assistant Core version: 2024.02

j2g2com commented 4 months ago

Localtuya version: 5.2.1 Home Assistant Core version: 2024.02 [] Does the device work using the Home Assistant Tuya Cloud component ? [x] [X] Does the device work using the Tinytuya (https://github.com/rospogrigio/localtuya) command line tool ? [] Was the device working with earlier versions of localtuya ? Which one? [X] Are you using the Tuya/SmartLife App in parallel ? [X]

When trying to add local tuya zigbee hub it gives me the following error

Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists.

2024-02-12 12:42:49.101 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending command 10 (device type: type_0a) 2024-02-12 12:42:49.101 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending payload: b'{"gwId":"bf332555cc01dfe814xir1","devId":"bf332555cc01dfe814xir1","uid":"bf332555cc01dfe814xir1","t":"1707738169"}' 2024-02-12 12:42:49.102 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Command 10 waiting for seq. number 1 2024-02-12 12:42:49.114 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'\x15\x9b\xdc\x10\xdf\x0b\x1a\x0f\xbcxW\x97\xe5k\xc2\xf4\xb9\x04p+\xe4P9\xafI\x86B\xec\x8d\xe8\xb54', crc=3936286838, crc_good=True) 2024-02-12 12:42:49.115 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] 'data unvalid' error detected: switching to dev_type 'type_0d' 2024-02-12 12:42:49.115 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Re-send 10 due to device type change (type_0a -> type_0d) 2024-02-12 12:42:49.115 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending command 10 (device type: type_0d) 2024-02-12 12:42:49.115 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending payload: b'{"devId":"bf332555cc01dfe814xir1","uid":"bf332555cc01dfe814xir1","t":"1707738169","dps":{"1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null,"9":null,"10":null}}' 2024-02-12 12:42:49.115 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Command 13 waiting for seq. number 2 2024-02-12 12:42:49.188 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Dispatching message CMD 13 TuyaMessage(seqno=2, cmd=13, retcode=0, payload=b'', crc=2380353348, crc_good=True) 2024-02-12 12:42:49.188 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] ACK received for command 13: ignoring it 2024-02-12 12:42:49.188 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending command 10 (device type: type_0d) 2024-02-12 12:42:49.189 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending payload: b'{"devId":"bf332555cc01dfe814xir1","uid":"bf332555cc01dfe814xir1","t":"1707738169","dps":{"1":null,"11":null,"12":null,"13":null,"14":null,"15":null,"16":null,"17":null,"18":null,"19":null,"20":null}}' 2024-02-12 12:42:49.189 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Command 13 waiting for seq. number 3 2024-02-12 12:42:49.268 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Dispatching message CMD 13 TuyaMessage(seqno=3, cmd=13, retcode=0, payload=b'', crc=1350014657, crc_good=True) 2024-02-12 12:42:49.268 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] ACK received for command 13: ignoring it 2024-02-12 12:42:49.268 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending command 10 (device type: type_0d) 2024-02-12 12:42:49.268 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending payload: b'{"devId":"bf332555cc01dfe814xir1","uid":"bf332555cc01dfe814xir1","t":"1707738169","dps":{"1":null,"21":null,"22":null,"23":null,"24":null,"25":null,"26":null,"27":null,"28":null,"29":null,"30":null}}' 2024-02-12 12:42:49.269 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Command 13 waiting for seq. number 4 2024-02-12 12:42:49.351 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Dispatching message CMD 13 TuyaMessage(seqno=4, cmd=13, retcode=0, payload=b'', crc=755273881, crc_good=True) 2024-02-12 12:42:49.351 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] ACK received for command 13: ignoring it 2024-02-12 12:42:49.351 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending command 10 (device type: type_0d) 2024-02-12 12:42:49.351 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Sending payload: b'{"devId":"bf332555cc01dfe814xir1","uid":"bf332555cc01dfe814xir1","t":"1707738169","dps":{"1":null,"100":null,"101":null,"102":null,"103":null,"104":null,"105":null,"106":null,"107":null,"108":null,"109":null,"110":null}}' 2024-02-12 12:42:49.352 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Command 13 waiting for seq. number 5 2024-02-12 12:42:49.449 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Dispatching message CMD 13 TuyaMessage(seqno=5, cmd=13, retcode=0, payload=b'', crc=4036118812, crc_good=True) 2024-02-12 12:42:49.449 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] ACK received for command 13: ignoring it 2024-02-12 12:42:49.449 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Detected dps: {} 2024-02-12 12:42:49.449 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {} 2024-02-12 12:42:49.449 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Closing connection 2024-02-12 12:42:49.450 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...ir1] Connection lost: None

Th0tti commented 4 months ago

same problem here with the Eightree Smart Plugs (e29)

rmattila74 commented 4 months ago

Close all Smart Life and Tuya apps.

blackshuck88 commented 4 months ago

I have the same problem. :-(

Home Assistant Core: 2024.2.1 Supervisor 2024.01.1 Operating System 11.5 Frontend 20240207.1 Local Tuya: 5.2.1 Devices: Smart Bulbs

I don't see any devices listed in LocalTuya integration. My subscription at IoT Platform is valid. I see all my devices there and they are linked properly to the SmartLife App. I tried to unlink and add again the SmartLife App at IoT Platform but without success.

Then I tried to add a device manually but receive always the same error message: "Connection to device succeeded but no datapoints found, please try again."

I have all needed device details (Name, Host, Device ID and Local key) and tried with all shown protocols (3.1, 3.2, 3.3, 3.4)

I can also ping all devices from the HA terminal.

I would also like to add that I can see all devices listed in diagnostics for integrations (config_entry-localtuya) but can't see them listed in the drop down menu when I try to add new device. And the Smart Life App is closed on all devices.

LocalTuya_Integration_Add Device

Thank you in advance for your support!

Here are two errors that I see in HA logs:


Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:863 Integration: LocalTuya integration (documentation, issues) First occurred: 08:08:21 (1 occurrences) Last logged: 08:08:21

[bf5...eva] 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


Logger: homeassistant Source: custom_components/localtuya/discovery.py:67 Integration: LocalTuya integration (documentation, issues) First occurred: 08:06:46 (240 occurrences) Last logged: 08:13:22

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() 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 84, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1234, 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 0xf6 in position 0: invalid start byte


jkdobro commented 4 months ago

same problem here with the e14 Candle Lamp W5052/WiFi 230v 5W

monotonus commented 4 months ago

Also tried it today and have the same issue. Is it because while linking the app there is no more the possibility to set the read/write permissions? So I just have read permissions for now on my device.

blackshuck88 commented 4 months ago

I have found out that if I add a DPS value 1 then it adds the new device but I can control it. :-(

I have added manually a new device, filled in the name, host, device ID and local key. In the second field, in manual DPS, I entered 1. Afterwards clicked on submit and when the box popped up I have selected "light". In the next section I have activated all values and submitted. Now I see the control panel but can't use it, It looks like all options are inactive. LocalTuya_Integration_DPS_Light

blackshuck88 commented 4 months ago

I have finally found a solution by installing LocalTuya "fork from localtuya" provided by hass-localtuya Here is detailed description.

To make it short. Here is the main installation guide:

1. Open HACS and navigate to Integrations Section.
2. Open the Overflow Menu (⋮) in the top right corner and click on Custom repositories.
3. Paste https://github.com/xZetsubou/localtuya into the input field and select Integration from the category dropdown then click ADD.
4. Now the integration should be added search in for it and install it!.

In my case the integration was already there. Just search for LocalTuya by xZetsubou. I didn't delete the previous version of LocalTuya.

I am impressed how stable this version is. Great job. Btw. This version uses the protocol 3.5.

hgregorian commented 3 months ago

Thanks for pointing this out. Works perfectly with Feit ST2160/RGBW/FIL/AG bulbs with protocol 3.5!

I have finally found a solution by installing LocalTuya "fork from localtuya" provided by hass-localtuya

Here is detailed description.

To make it short. Here is the main installation guide:

1. Open HACS and navigate to Integrations Section.

2. Open the Overflow Menu (⋮) in the top right corner and click on Custom repositories.

3. Paste https://github.com/xZetsubou/localtuya into the input field and select Integration from the category dropdown then click ADD.

4. Now the integration should be added search in for it and install it!.

In my case the integration was already there. Just search for LocalTuya by xZetsubou. I didn't delete the previous version of LocalTuya.

I am impressed how stable this version is. Great job. Btw. This version uses the protocol 3.5.

muava12 commented 2 months ago

Thanks, work also for my some tuya bulbs and socket

I have finally found a solution by installing LocalTuya "fork from localtuya" provided by hass-localtuya Here is detailed description.

To make it short. Here is the main installation guide:

1. Open HACS and navigate to Integrations Section.
2. Open the Overflow Menu (⋮) in the top right corner and click on Custom repositories.
3. Paste https://github.com/xZetsubou/localtuya into the input field and select Integration from the category dropdown then click ADD.
4. Now the integration should be added search in for it and install it!.

In my case the integration was already there. Just search for LocalTuya by xZetsubou. I didn't delete the previous version of LocalTuya.

I am impressed how stable this version is. Great job. Btw. This version uses the protocol 3.5.