jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
867 stars 157 forks source link

Cannot connect to smart plug over local API #495

Closed apach3guy closed 1 month ago

apach3guy commented 1 month ago

Having issues connecting to a smart plug over the tuya local API. I confirmed that I can connect to the plug over LAN on port 6668, so it should be supported.

root@odroid:~# nc -v -z -w 5 192.168.2.215 6668 Connection to 192.168.2.215 6668 port [tcp/*] succeeded!

I ran tinytuya in debug mode. It seems the plug is not sending any data.

DEBUG:building command 10 payload=b'{"gwId":"eb1f39ea47707b153elyqd","devId":"eb1f39ea47707b153elyqd","uid":"eb1f39ea47707b153elyqd","t":"1715306590"}' DEBUG:sending payload DEBUG:payload encrypted=b'000055aa00xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' DEBUG:_recv_all(): no data? b'' DEBUG:_recv_all(): no data? b'' DEBUG:Error decoding received data - read retry 0/5

Here's the device info:

"active_time": 1715134544, "biz_type": 0, "category": "cz", "create_time": 1715134544, "icon": "smart/icon/ay15306906879543yc3O/7d74e964c18077532998cf24d441d9f5.png", "id": "eb1f39ea47707b153elyqd", "ip": "xxxxxxxxxxxx", "lat": "", "local_key": "xxxxxxxxxxxxxx", "lon": "", "model": "\u666e\u901a\u63d2\u5ea7", "name": "Lamp", "online": true, "owner_id": "xxxxxxxxxxxxxxx", "product_id": "ijo85n3r377lvbse", "product_name": "Smart plug", "status":

I'm using TinyTuya [1.13.2]

jasonacox commented 1 month ago

Hi @apach3guy , suggestions:


# Connect to Device
d = tinytuya.OutletDevice(
    dev_id='DEVICE_ID_HERE',
    address='IP_ADDRESS_HERE',      # Or set to 'Auto' to auto-discover IP address
    local_key='LOCAL_KEY_HERE', 
    version=3.3)

d.status()
apach3guy commented 1 month ago

Thanks. It works with version 3.4 only. I tried version 3.3 and 3.5 which do not work.

jasonacox commented 1 month ago

Thanks! What was the fix? Just switching to 3.4?