jasonacox / tinytuya

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

Empty key from scan #553

Open thewh1teagle opened 2 hours ago

thewh1teagle commented 2 hours ago

When I scan the devices I get empty keys so can't control them. I have heater, switch, and lamp.

"python .\test.py       
DEBUG:TinyTuya [1.15.1]

DEBUG:Python 3.12.5 on win32
DEBUG:Using pyca/cryptography 43.0.3 for crypto, GCM is supported

TinyTuya (Tuya device scanner) [1.15.1]

Scanning on UDP ports 6666 and 6667 and 7000 for devices for 18 seconds...

DEBUG:Listening for Tuya devices on UDP ports 6666, 6667 and 7000
DEBUG:Sending discovery broadcast from 'your_ip_address' to '255.255.255.255' on port 7000
DEBUG:Received valid UDP packet: {'from': 'app', 'ip': 'your_ip_address'}
New Broadcast from App at your_ip_address - {'from': 'app', 'ip': 'your_ip_address'}
DEBUG:Received valid UDP packet: {'from': 'app', 'ip': 'your_ip_address'}
DEBUG:Received valid UDP packet: {'ip': 'device_ip_1', 'gwId': 'device_gwId_1', 'active': 2, 'ability': 0, 'mode': 0, 'encrypt': True, 'productKey': 'productKey_1', 'version': '3.1'}
DEBUG:final payload_dict for 'device_gwId_1' ('v3.1'/'default'): { ... }
DEBUG:building command 10 payload=b'{"gwId":"device_gwId_1","devId":"device_gwId_1","uid":"device_gwId_1","t":"timestamp"}'
DEBUG:payload encrypted=b'...'
DEBUG:PollDevice: raw unpacked message = ...
DEBUG:decode payload=b'...'
DEBUG:decoded results='...'
Unknown v3.1 Device   Product ID = productKey_1  [Valid Broadcast]:
    Address = device_ip_1   Device ID = device_gwId_1   Version = 3.1  Type = default
    Status: {...}
DEBUG:Received valid UDP packet: {'ip': 'device_ip_2', 'gwId': 'device_gwId_2', 'active': 2, 'encrypt': True, 'productKey': 'productKey_2', 'version': '3.3'}
Unknown v3.3 Device   Product ID = productKey_2  [Valid Broadcast]:
    Address = device_ip_2   Device ID = device_gwId_2   Version = 3.3  Type = default

Scan completed in 18.0915 seconds

Scan Complete!  Found 2 devices.
Broadcasted: 2
Versions: 3.1: 1, 3.3: 1
Unknown Devices: 2

>> Saving device snapshot data to snapshot.json

DEBUG:Scan complete with 2 devices found"

removed sensitive data

jasonacox commented 2 hours ago

Hi @thewh1teagle - you will need to get the local keys before scan will be able to read the devices. Follow the instructions here: https://github.com/jasonacox/tinytuya?tab=readme-ov-file#setup-wizard---getting-local-keys

python3 -m tinytuya wizard