Open sjmotew opened 3 years ago
Hi @sjmotew - This error is indicative of a problem with your apiKey
& apiSecret
values or settings in your Tuya Developer account.
Check section 3 of the following and double check IMPORTANT part - (see screenshot here)
https://github.com/jasonacox/tinytuya#setup-wizard
Jason,
All is set up correctly, and I just left the API and secret blank above to conceal. Is this occurring perhaps because I am trying to attach a non-standard Tuya device (Recteq Smoker) that does not appear on the Smart Life App? The Recteq app is based on Tuya but it is not a Tuya identifiable device. It is found by tuyapower but cannot read the key which is what I need.
Any thoughts would be helpful, thanks for your work.
Yes - The Device ID must be in Smart Life app or listed in iot.tuya.com portal as paired or the wizard won't work. Tuya requires a valid paring with the app to provide the local key. The local key is created when you pair (a new one every time you pair). Do you have other Tuya devices you can use? It just needs one valid one to give you all of them.
Is the Smoker dev battery powered? If so, important Note: Battery-powered Tuya sensors are usually designed to stay in sleep mode until a state change (eg. temp chg, open or close alert). This means you will not be able to poll these devices except in the brief moment they awake, connect to the WiFi and send their state update payload the the Tuya Cloud. Keep in mind that if you manage to poll the device enough to keep it awake, you may drain the battery.
Yes I have other Tuya devices, I will link them (which I haven't done yet) and then try again. The smoker is not battery. Thanks.
It is finding the 2 devices on Tuyapower, one is the app-registered "String Lights", the other is at IP: 10.0.20.26, which is the Recteq smoker. tintuya recognizes the presence 2 devices but will not show the snapshot details including key, only returns the registered device.
Here is the output:
from tuyapower
` TuyaPower (Tuya compatible smart plug scanner) [0.0.25] tinytuya [1.2.3]
Scanning on UDP ports 6666 and 6667 for devices (15 retries)...
FOUND Device [Valid payload]: 10.0.20.246 ID = eb726cece74119f0bf6atu, product = keyxkjmf8q7ht44p, Version = 3.3 Device Key required to poll for stats FOUND Device [Valid payload]: 10.0.20.26 ID = 06200290b4e62d195c2f, product = 1CwNbNLE8r70WR7t, Version = 3.1 Stats: on=True [Power data unavailable]
Scan Complete! Found 2 devices.
`
from tinytuya wizard ` Existing settings: API Key=pp45rdrwaht9z3l2n21p Secret=94fb6c5e9e534decaed5e07039397973 DeviceID=eb726cece74119f0bf6atu Region=us
Use existing credentials (Y/n): Y
Device Listing
[ { "name": "String Lights", "id": "eb726cece74119f0bf6atu", "key": "abccba4985d62425" } ]
Saving list to devices.json 1 registered devices saved
Poll local devices? (Y/n): Y
Scanning local network for Tuya devices... 2 local devices discovered
Polling local devices... [String Lights] - 10.0.20.246 - No Response
Saving device snapshot data to snapshot.json
Done. ` From snapshot.json:
{ "timestamp": 1618263773.9440472, "devices": [ { "name": "String Lights", "ip": "10.0.20.246", "ver": "3.3", "id": "eb726cece74119f0bf6atu", "key": "abccba4985d62425" } ] }
The Tuya cloud will only return keys for devices that have been paired. That may be why are you still not getting the key. Can you pair the Smoker with the SmartLife app?
Try to scan now that you have the key for "String Lights". Ensure you do not have the app (e.g. SmartLife) open many of the Tuya devices only allow one connection at a time and refuse others. Some things to try:
python -m tinytuya scan # this will scan network and reference the devices.json file to apply key
Are you able to ping 10.0.20.26
and get a response from that device? You can try this debug code snip to see more details on the tuyaprotocol (try on both devices if you can):
import tinytuya
print("TinyTuya (Tuya Interface) [%s]\n"%tinytuya.__version__)
tinytuya.set_debug(True)
d = tinytuya.OutletDevice(DEVICEID, DEVICEIP, DEVICEKEY)
print(d)
d.set_version(3.1)
print(" > Fetch Status < ")
data = d.status()
print(data)
I was able to directly pair with the SmartLife app using a generic wifi device. Solved all the issues, I can now run from SmartLife or as intended have extracted the key for use with Home Assistant. Great problem solving, I will share and link back on the Home Assistant site.
Excellent! Thanks for the update @sjmotew !
Great app, thank you. Running on MAC trying to find the LOCALKEY for a Recteq grill. Tuyapower identifies the device with device ID, IP etc.. Followed all API Tuya developer instructions and when running tinytuya receive:
`{ "apiKey": "<>",
"apiSecret": "<>",
"apiRegion": "us",
"apiDeviceID": "06200290b4e62d195c2f"
}
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tinytuya/main.py", line 49, in
wizard.wizard(color)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tinytuya/wizard.py", line 206, in wizard
uid = response_dict['result']['uid']
KeyError: 'result'`