jasonacox / tinytuya

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

Question on the wizard and scan function #130

Open Jamie-Geoghegan opened 2 years ago

Jamie-Geoghegan commented 2 years ago

Hi there,

I was wondering something about these methods, are you calling any tuya apis during these wizard and command executions, my goal is to be able to get all of the DP's while not being connected to the wifi the device is on, going off of the tuya apis status functions I get a limited set of DPs compared to the Full range of DP's I get when I use your wizard/scan command

If you could point me in the direction of an api that gets me the full range of dps using a device on a different network i'd very much appreciate it.

jasonacox commented 2 years ago

Hi @Jamie-Geoghegan !

TinyTuya wizard uses the Tuya Cloud to get the list of devices and their local keys. This only needs to be run once. Once you have the local key, you do not need the internet to connect to these devices.

python3 -m tinyutya wizard

The wizard will record those keys in the devices.json file. You can then run either of these commands to have TinyTuya scan these devices without using the internet (no Tuya Cloud access):

# Show the list of device IDs + keys and optionally determine IPs and poll all devices
python3 -m tinytuya devices

# Quickly poll the devices from the snapshot.json file created by scan commands
python3 -m tinytuya snapshot

You can also write your own python script to get the DPS:

import tinytuya

# Connect to the device - replace with real values
d=tinytuya.OutletDevice(DEVICEID, DEVICEIP, DEVICEKEY)
d.set_version(3.3)

# Get the status of the device 
data = d.get_status()
print(data)
jasonacox commented 1 year ago

I may have misunderstood your request. I suspect you may be looking more for something like this: https://github.com/jasonacox/tinytuya/discussions/284