-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot connect to local device #543
Comments
Hi @wallforfry , I would try: import tinytuya
# Turn on debug
tinytuya.set_debug(True)
# Connect to Device
d = tinytuya.OutletDevice(
dev_id='DEVICE_ID_HERE',
address='192.168.1.13',
local_key='LOCAL_KEY_HERE',
version=3.3)
# Get Status
data = d.status()
print('set_status() result %r' % data) |
Thank's for your fast answer, just tried and got : DEBUG:TinyTuya [1.15.1]
DEBUG:Python 3.13.0 (main, Oct 7 2024, 05:02:14) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
DEBUG:Using pyca/cryptography 43.0.1 for crypto, GCM is supported
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for '40330123ecfabcbec3b8' ('v3.3'/'default'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'devId': '', 'uid': '', 't': ''}}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 13: {'command': {'devId': '', 'uid': '', 't': ''}}, 16: {'command': {'devId': '', 'uid': '', 't': ''}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"gwId":"40330123ecfabcbec3b8","devId":"40330123ecfabcbec3b8","uid":"40330123ecfabcbec3b8","t":"1728632161"}'
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000010000000a00000078c4662892a437a0f9b3a11bbf78afdb47421335f00a9dbd1fb382b4cfd3e44377d578f25ac81a352a70ef380c322ee7932a519fef2734c5f3b2f5fe74845ee53d693f3dbe2ab05d42bb72c36668f8e325b330da25a76ddab7eed7f4a2c2ca1e5c57fa26e2643888d1d502be4001871511f1bbec5e0000aa55'
DEBUG:Network connection error in _send_receive() - retry 1/5
Traceback (most recent call last):
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1144, in _send_receive
self.socket.sendall(enc_payload)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
BrokenPipeError: [Errno 32] Broken pipe
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000020000000a00000078c4662892a437a0f9b3a11bbf78afdb47421335f00a9dbd1fb382b4cfd3e44377d578f25ac81a352a70ef380c322ee7932a519fef2734c5f3b2f5fe74845ee53d693f3dbe2ab05d42bb72c36668f8e325b330da25a76ddab7eed7f4a2c2ca1e5c57fa26e2643888d1d502be40018715111fddef470000aa55'
DEBUG:Network connection error in _send_receive() - retry 2/5
Traceback (most recent call last):
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1149, in _send_receive
rmsg = self._receive()
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1037, in _receive
data = self._recv_all( min_len )
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1011, in _recv_all
newdata = self.socket.recv(length)
ConnectionResetError: [Errno 54] Connection reset by peer
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000030000000a00000078c4662892a437a0f9b3a11bbf78afdb47421335f00a9dbd1fb382b4cfd3e44377d578f25ac81a352a70ef380c322ee7932a519fef2734c5f3b2f5fe74845ee53d693f3dbe2ab05d42bb72c36668f8e325b330da25a76ddab7eed7f4a2c2ca1e5c57fa26e2643888d1d502be4001871511f32f138f0000aa55'
DEBUG:Network connection error in _send_receive() - retry 3/5
Traceback (most recent call last):
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1149, in _send_receive
rmsg = self._receive()
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1037, in _receive
data = self._recv_all( min_len )
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1011, in _recv_all
newdata = self.socket.recv(length)
ConnectionResetError: [Errno 54] Connection reset by peer
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000040000000a00000078c4662892a437a0f9b3a11bbf78afdb47421335f00a9dbd1fb382b4cfd3e44377d578f25ac81a352a70ef380c322ee7932a519fef2734c5f3b2f5fe74845ee53d693f3dbe2ab05d42bb72c36668f8e325b330da25a76ddab7eed7f4a2c2ca1e5c57fa26e2643888d1d502be40018715111860ef340000aa55'
DEBUG:Network connection error in _send_receive() - retry 4/5
Traceback (most recent call last):
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1149, in _send_receive
rmsg = self._receive()
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1037, in _receive
data = self._recv_all( min_len )
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1011, in _recv_all
newdata = self.socket.recv(length)
ConnectionResetError: [Errno 54] Connection reset by peer
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000050000000a00000078c4662892a437a0f9b3a11bbf78afdb47421335f00a9dbd1fb382b4cfd3e44377d578f25ac81a352a70ef380c322ee7932a519fef2734c5f3b2f5fe74845ee53d693f3dbe2ab05d42bb72c36668f8e325b330da25a76ddab7eed7f4a2c2ca1e5c57fa26e2643888d1d502be4001871511f49213fc0000aa55'
DEBUG:Network connection error in _send_receive() - retry 5/5
Traceback (most recent call last):
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1149, in _send_receive
rmsg = self._receive()
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1037, in _receive
data = self._recv_all( min_len )
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1011, in _recv_all
newdata = self.socket.recv(length)
ConnectionResetError: [Errno 54] Connection reset by peer
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000060000000a00000078c4662892a437a0f9b3a11bbf78afdb47421335f00a9dbd1fb382b4cfd3e44377d578f25ac81a352a70ef380c322ee7932a519fef2734c5f3b2f5fe74845ee53d693f3dbe2ab05d42bb72c36668f8e325b330da25a76ddab7eed7f4a2c2ca1e5c57fa26e2643888d1d502be40018715111af410e50000aa55'
DEBUG:Network connection error in _send_receive() - retry 6/5
Traceback (most recent call last):
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1149, in _send_receive
rmsg = self._receive()
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1037, in _receive
data = self._recv_all( min_len )
File "/private/tmp/venv/lib/python3.13/site-packages/tinytuya/core.py", line 1011, in _recv_all
newdata = self.socket.recv(length)
ConnectionResetError: [Errno 54] Connection reset by peer
DEBUG:Exceeded tinytuya retry limit (5)
DEBUG:Unable to connect to device
DEBUG:ERROR Network Error: Unable to Connect - 901 - payload: null
DEBUG:status() received data={'Error': 'Network Error: Unable to Connect', 'Err': '901', 'Payload': None}
set_status() result {'Error': 'Network Error: Unable to Connect', 'Err': '901', 'Payload': None} Side note: when I used localtuya before, I had to put
But I think that your "default" dev_type already handle that |
How do you know it's a v3.3 device? That error's looking like it's either a different version or there is already a connection to it open from another program. A lot of devices stop broadcasting discovery packets when a connection is made, which would also explain the "not found by scan" issue. |
@uzlonewolf I previously connect it with localtuya which totally works with 3.3 version. Then I reset the device to renew the localkey and stop all others connections (also closed the smartlife mobile app just after pairing). I'll try to do it again multiple times just in case 🤞 |
Hi !
I'm trying to connect my Avidsen Homefresh AC but it's never found by the scan command.
I know that it's a v3.3 Tuya API, I've got the right key and deviceId.
I tried to run a custom script calling the
find_device
function. This gave me some results but idk what to do know. Is this encrypted payload normal ?I tried with a
status()
call too, but it always ends withsocket unable to connect
Also :
The text was updated successfully, but these errors were encountered: