-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
d.status() not working #16
Comments
Can you paste the code you are using (AA.py)? Based on the error trace, it is getting a null response (None). Also are you seeing the outlet when you do a scan?:
|
Thanks for the tests! There seems to be some strange behavior with some devices that have a 22 character IDs. I don't know if that is your case. Try adding device22 to the initialization for dev_type: a = tinytuya.OutletDevice('here_is_my_key', '192.168.1.9', 'secret_key_here', 'device22')
a.set_version(3.3)
data = a.status()
print(data) Also, in case it helps, I see you are using a Windows command window instead of a powershell terminal. Tinytuya sends terminal color codes that don't show up in command windows, but you can disable color codes: python -m tinytuya scan -nocolor If you can, I would also recommend pulling the local key again and let tinytuya run a scan on the device as well: python -m tinytuya wizard -nocolor Finally, if none of that helps, make sure there isn't a firmware update for the device (I have seem some odd tuya behavior on early 3.3 devices). |
The wizard produced the same local key as before, but my device has indeed a 22 character id. By using "device22" the error changed into this:
I don't know if could be useful to you, but by using the tuyapy module I am able to retrieve the on/off status correctly (that module is using the cloud based approach though). |
Ah! That's encouraging result. I left out a line, try this (notice set_dpsUsed): a = tinytuya.OutletDevice('here_is_my_key', '192.168.1.9', 'secret_key_here', 'device22')
a.set_version(3.3)
a.set_dpsUsed({"1": None})
data = a.status()
print(data) I need to add code to the library to automatically try device22 specifics for those edge-case devices. It's on my list. ;) |
Solved! 🎉🎉 |
The outlet is correctly turning on and off, but d.status() is raising a JSONDecodeError
Traceback (most recent call last): File "C:/Users/theco/Desktop/AA.py", line 11, in <module> data= d.status() File "C:\Users\theco\AppData\Local\Programs\Python\Python39\lib\site-packages\tinytuya\__init__.py", line 502, in status result = json.loads(result) File "C:\Users\theco\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\theco\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\theco\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Any help on this?
The text was updated successfully, but these errors were encountered: