rospogrigio / localtuya

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

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

Open WilliamTian0987 opened 1 year ago

WilliamTian0987 commented 1 year ago

The problem

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

Environment

Steps to reproduce

  1. Add a new device .
  2. Choose the gateway device and submit.
  3. Fill in the device details and submit.

DP dump

INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)] on win32
INFO:localtuya:Using pytuya version '10.0.0'
INFO:localtuya:Detecting list of available DPS of device 6c65130xxxxxxxxx1chcv4 [10.1.1.250], protocol 3.3.
DEBUG:localtuya.pytuya:[6c6...cv4] Sending command 10 (device type: type_0a)
DEBUG:localtuya.pytuya:[6c6...cv4] Sending payload: b'{"gwId":"6c65130xxxxxxxxx1chcv4","devId":"6c65130xxxxxxxxx1chcv4","uid":"6c65130xxxxxxxxx1chcv4","t":"1675096007"}'
DEBUG:localtuya.pytuya:[6c6...cv4] Command 10 waiting for sequence number 1
DEBUG:localtuya.pytuya:[6c6...cv4] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b"=\x9a\xc3\x8d\xe0\x0e\xe6\xceu\xfd\xd2\x10\xf0\xc7t\x92'\x8fJ\xad\xd1\xf5\xd5\xec\xa1\xdbx\x0b~\xeeC\x1b", crc=3821050936, crc_good=True)
DEBUG:localtuya.pytuya:[6c6...cv4] 'data unvalid' error detected: switching to dev_type 'type_0d'
DEBUG:localtuya.pytuya:[6c6...cv4] Re-send 10 due to device type change (type_0a -> type_0d)
DEBUG:localtuya.pytuya:[6c6...cv4] Sending command 10 (device type: type_0d)
DEBUG:localtuya.pytuya:[6c6...cv4] Sending payload: b'{"devId":"6c65130xxxxxxxxx1chcv4","uid":"6c65130xxxxxxxxx1chcv4","t":"1675096007","dps":{"1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null,"9":null,"10":null}}'
DEBUG:localtuya.pytuya:[6c6...cv4] Command 13 waiting for sequence number 2
DEBUG:localtuya.pytuya:[6c6...cv4] Dispatching message CMD 13 TuyaMessage(seqno=2, cmd=13, retcode=0, payload=b'', crc=2380353348, crc_good=True)
DEBUG:localtuya.pytuya:[6c6...cv4] ACK received for command 13: ignoring it
DEBUG:localtuya.pytuya:[6c6...cv4] Sending command 10 (device type: type_0d)
DEBUG:localtuya.pytuya:[6c6...cv4] Sending payload: b'{"devId":"6c65130xxxxxxxxx1chcv4","uid":"6c65130xxxxxxxxx1chcv4","t":"1675096007","dps":{"1":null,"11":null,"12":null,"13":null,"14":null,"15":null,"16":null,"17":null,"18":null,"19":null,"20":null}}'
DEBUG:localtuya.pytuya:[6c6...cv4] Command 13 waiting for sequence number 3
DEBUG:localtuya.pytuya:[6c6...cv4] Dispatching message CMD 13 TuyaMessage(seqno=3, cmd=13, retcode=0, payload=b'', crc=1350014657, crc_good=True)
DEBUG:localtuya.pytuya:[6c6...cv4] ACK received for command 13: ignoring it
DEBUG:localtuya.pytuya:[6c6...cv4] Sending command 10 (device type: type_0d)
DEBUG:localtuya.pytuya:[6c6...cv4] Sending payload: b'{"devId":"6c65130xxxxxxxxx1chcv4","uid":"6c65130xxxxxxxxx1chcv4","t":"1675096007","dps":{"1":null,"21":null,"22":null,"23":null,"24":null,"25":null,"26":null,"27":null,"28":null,"29":null,"30":null}}'
DEBUG:localtuya.pytuya:[6c6...cv4] Command 13 waiting for sequence number 4
DEBUG:localtuya.pytuya:[6c6...cv4] Dispatching message CMD 13 TuyaMessage(seqno=4, cmd=13, retcode=0, payload=b'', crc=755273881, crc_good=True)
DEBUG:localtuya.pytuya:[6c6...cv4] ACK received for command 13: ignoring it
DEBUG:localtuya.pytuya:[6c6...cv4] Sending command 10 (device type: type_0d)
DEBUG:localtuya.pytuya:[6c6...cv4] Sending payload: b'{"devId":"6c65130xxxxxxxxx1chcv4","uid":"6c65130xxxxxxxxx1chcv4","t":"1675096007","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}}'
DEBUG:localtuya.pytuya:[6c6...cv4] Command 13 waiting for sequence number 5
DEBUG:localtuya.pytuya:[6c6...cv4] Dispatching message CMD 13 TuyaMessage(seqno=5, cmd=13, retcode=0, payload=b'', crc=4036118812, crc_good=True)
DEBUG:localtuya.pytuya:[6c6...cv4] ACK received for command 13: ignoring it
DEBUG:localtuya.pytuya:[6c6...cv4] Detected dps: {}
AVAILABLE DPS ARE [{}]
INFO:localtuya:COMPLETE response from device 6c65130xxxxxxxxx1chcv4 [10.1.1.250].

**** deviceInfo returned OK ****

TuyaDebug (Tuya DPs dump) [1.0.0]

Device 6c65130xxxxxxxxx1chcv4 at 10.1.1.250 key 85000e2d3636415f protocol 3.3 dev_type type_0d:
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000028CC6BC21F0>
Traceback (most recent call last):
  File "G:\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "G:\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "G:\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "G:\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Provide Home Assistant traceback/logs


Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:662
Integration: LocalTuya integration (documentation, issues)
First occurred: 00:11:17 (8 occurrences)
Last logged: 00:13:26

[6c6...cv4] Got message type 3 for unknown listener 1: TuyaMessage(seqno=1, cmd=3, retcode=1, payload=b'\xa7j:\xae', crc=b'\xb8\x07!e\x9d\x95\x8c\x0bD\xd2@\x95\xe7\xe0]\x94\xa0\x81\xf7\xdf\x08k\xe7\x8eXi\xaaZR\xb8\xfc\xd3', crc_good=False)
[6c6...cv4] Got message type 3 for unknown listener 3: TuyaMessage(seqno=3, cmd=3, retcode=1, payload=b'\xa7j:\xae', crc=b'\xb8\x07!e\x9d\x95\x8c\x0bD\xd2@\x95\xe7\xe0]\x94\xa0\x81\xf7\xdf\x08k\xe7\x8eXi\xaaZ\xce\xe5\xaa\n', crc_good=False)
[6c6...cv4] Got message type 3 for unknown listener 5: TuyaMessage(seqno=5, cmd=3, retcode=1, payload=b'\xa7j:\xae', crc=b'\xb8\x07!e\x9d\x95\x8c\x0bD\xd2@\x95\xe7\xe0]\x94\xa0\x81\xf7\xdf\x08k\xe7\x8eXi\xaaZ\xb1sW ', crc_good=False)
[6c6...cv4] Got message type 3 for unknown listener 7: TuyaMessage(seqno=7, cmd=3, retcode=1, payload=b'\xa7j:\xae', crc=b'\xb8\x07!e\x9d\x95\x8c\x0bD\xd2@\x95\xe7\xe0]\x94\xa0\x81\xf7\xdf\x08k\xe7\x8eXi\xaaZ-.\x01\xf9', crc_good=False)

此错误来自自定义集成。

Additional information

arkansas-coder commented 1 year ago

Have the same problem but have different output. Verified that datapoints exist.

Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:450 Integration: LocalTuya (documentation, issues) First occurred: 2:33:13 PM (2 occurrences) Last logged: 2:35:34 PM

[ebc...ym2] 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 857, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 789, in status status = await self.exchange(DP_QUERY) File "/config/custom_components/localtuya/pytuya/init.py", line 763, 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.10/asyncio/tasks.py", line 458, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

djamelinfo commented 1 year ago

I also have the same problem when I try to add a new device: image

` Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:450 Integration: LocalTuya (documentation, issues) First occurred: 14:44:15 (1 occurrences) Last logged: 14:44:15 [201...c95] 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 857, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 789, in status status = await self.exchange(DP_QUERY) File "/config/custom_components/localtuya/pytuya/init.py", line 763, 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.10/asyncio/tasks.py", line 458, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError`

wjgregory commented 1 year ago

I am also seeing this problem. I noticed that the "Local key" field is not being filled in automatically as it has done in the past.

kizovinh commented 1 year ago

I have the same issue, my device is Petree gen 2 Cat toilet

klona commented 1 year ago

same here : https://github.com/rospogrigio/localtuya/issues/1254

paoloantinori commented 1 year ago

Same error with different logs:

2023-02-06 10:28:52.093 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] Sending command 10 (device type: type_0a)
2023-02-06 10:28:52.093 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] Sending payload: b'{"gwId":"MY_ID_HERE","devId":"MY_ID_HERE","uid":"MY_ID_HERE","t":"1675675732"}'
2023-02-06 10:28:52.102 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] Command 10 waiting for sequence number 1
2023-02-06 10:28:52.108 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=0, payload=b"!G[&S\xed\x12Y9\xba*1\x00\xf2\xdbzC\x13\xc86AX<8\xe8\xbb\xe3Ol\xfeN\xa2\x7fdAzxdr\xeb\xda\x98r\xa0\x93y\xc7t]\x90_\x13\x8c\x90r\xb4\x12\xcd\r\xfbe\xd8\xed,(Z\xc7;<\xb4+r\xedN\xa1\x0cH\xb5\xde\x89P\xbf\x14\xa0?*\x11\xc3\x80\xefJ\xdc\x18\n\xc1\xd3\x8eT\xd8w%\xfa6\nr-\xdf\xaa\x11\x90\xe8\x88\xa5\x0bE',#\xd4\x85y\xae\xc1?p\x04O\x06\xf1l\xfaQ.\xed\xd6\x9c\x89\xb9C\xe4&\xacp ", crc=1474611291, crc_good=True)
2023-02-06 10:28:52.110 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] incomplete payload=b"!G[&S\xed\x12Y9\xba*1\x00\xf2\xdbzC\x13\xc86AX<8\xe8\xbb\xe3Ol\xfeN\xa2\x7fdAzxdr\xeb\xda\x98r\xa0\x93y\xc7t]\x90_\x13\x8c\x90r\xb4\x12\xcd\r\xfbe\xd8\xed,(Z\xc7;<\xb4+r\xedN\xa1\x0cH\xb5\xde\x89P\xbf\x14\xa0?*\x11\xc3\x80\xefJ\xdc\x18\n\xc1\xd3\x8eT\xd8w%\xfa6\nr-\xdf\xaa\x11\x90\xe8\x88\xa5\x0bE',#\xd4\x85y\xae\xc1?p\x04O\x06\xf1l\xfaQ.\xed\xd6\x9c\x89\xb9C\xe4&\xacp " (len:144)
2023-02-06 10:28:52.110 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] ERROR Unexpected Payload from Device - 904 - payload: null
2023-02-06 10:28:52.111 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
2023-02-06 10:28:52.111 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] Closing connection
2023-02-06 10:28:52.120 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf8...ybo] Connection lost: None

FWIW it did work, this is what I'm getting after I had removed the device and tried to add it back.

Gonzalo933 commented 1 year ago

I was experiencing the same problem the other day. I turned off the device for some time (to reset the localkey) and got it working with the new localkey

wjgregory commented 1 year ago

Turning off the device for a period of time (over night) did not work for me. However, I think I know what the issue might be, at least for me. I tried to follow a procedure I found on YouTube (https://www.youtube.com/watch?v=Q1ZShFJDvE0) to obtain my local key for the device in question. I got "msg": "No permissions. Your subscription to cloud development plan has expired." I had noticed that when I setup the account (within the last few months) it something about a 30 day trial subscription. I paid no mind to it and was able to add seven devices and it all worked fine. It was when I tried to add the latest device that it failed to work. So apparently they now want money to do this whereas in the past this basic use of their infrastructure was given a free pass. There are plenty of other devices that can do automation that will not rely on a subscription to setup so I am parting ways with Tuya.

Gonzalo933 commented 1 year ago

@wjgregory You can extend the free trial for another 6 months. Check Q3 from here: https://github.com/tuya/tuya-home-assistant/blob/main/docs/faq.md

Also you can retrieve your local keys without having to connect to Tuya cloud. Follow this tutorial: https://www.youtube.com/watch?v=YKvGYXw-_cE

wjgregory commented 1 year ago

@Gonzalo933 - Thanks for the tip. Did the extension and now it all works ... for now. Basically will I have to extend every 6 months or at some point will they decline?

Gonzalo933 commented 1 year ago

You could do that (people have extended the trial multiple times successfully) but I recommend that now you follow the steps to get the local keys for your devices and get localtuya working

On Sat, Feb 18, 2023, 11:46 wjgregory @.***> wrote:

@Gonzalo933 https://github.com/Gonzalo933 - Thanks for the tip. Did the extension and now it all works ... for now. Basically will I have to extend every 6 months or at some point will they decline?

— Reply to this email directly, view it on GitHub https://github.com/rospogrigio/localtuya/issues/1269#issuecomment-1435714557, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFVNKRJOUTLA36XPEOZCQ3WYD4HRANCNFSM6AAAAAAULLSJA4 . You are receiving this because you were mentioned.Message ID: @.***>

Gonzalo933 commented 1 year ago

I think the reason that localtuya can't connect to the device is that the device disconnects itself from the network in order to save battery. It reconnects itself every 5 minutes, sends data and disconnects. Probably the "online" window is really short to be picked up by localtuya