Closed markoloko1223 closed 10 months ago
It's fine to snip the device ID and local key, but we really need to see the rest of that tinytuya.OutletDevice() line. Are you setting version=...
in it? The correct version needs to be set or it won't work.
no i dont have version=... in it and how can i obtain it? btw heres the corrected code:
import tinytuya
switch = tinytuya.OutletDevice("bfaab3b4dbe7999840fauu","no",">nEx=u+fu!Y}Cj#O")
data = switch.status()
print('set_status() result %r' % data)
try:
# Attempt to control the device
response = switch.turn_on()
print(response) # Print the response received from the device
except Exception as e:
print(f"Error: {str(e)}")
Hi @markoloko1223 - you should see the version when you run the scanner:
python3 -m tinytuya scan
It will look something like this:
Unknown v3.3 Device Product ID = MShdslm9Uw7Q59nN [Valid Broadcast]:
Address = 10.0.x.x Device ID = xxxxxxxxxxxxx (len:20) Local Key = xxxxxxxxx
Version = 3.3 Type = default, MAC = xx:xx:xx:xx:xx:xx
An example of how to use the tinytuya library is here:
import tinytuya
# 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) # This is where you set the version
# Get Status
data = d.status()
print('set_status() result %r' % data)
# Turn On
d.turn_on()
# Turn Off
d.turn_off()
still the same error
even with version included
nevermind it works now thank you so much
so i have the SHLS111W smart switch model (wifi) and whenever i do
switch,turn_on()
it does not turn on my light, i didnt know why and im kind of a beginner in python so i asked chat gpt for help and it said to enter this into my code:and i got the error
{'Error': 'Unexpected Payload from Device', 'Err': '904', 'Payload': ''}
i completed the setup like it said in the documentation and nothing. i made sure that everything is correct. heres my code: