Closed vespino closed 5 months ago
Hi, That is line 224 isthe "self.tuya.refresh_access_token()" normally when you stop the plugin for 5 to 10 minutes and then restart it. This action should obtain a new token.
@Xenomes I don’t quite understand. I found the line of code and understand what it does, but I don’t stop the plugin at any point. Should this be a “status” instead of a “problem” entry?
I don't run this plugin 24/7 anymore, the used python module is end of live, Tuya announce that they will stop that connection where the module hook in too. Maybe the server is not running perfect anymore.
Bullocks. So their cloud api is the only option looking towards the future?
I have created a bunch of dummy switches and am now controlling my lights and switches using the cloud api. Thanks for your work supporting this plugin.
I have build a other plugin witch is using the Tinytuya module, https://github.com/Xenomes/Domoticz-TinyTUYA-Plugin and https://github.com/Xenomes/Domoticz-TinyTUYA-Local-Plugin But this is now only support on/off.
And these also load the devices automatically? I’m using switches and rgb lights at the moment, nothing else, so I might give those a try.
Yes they chould work!
First attempt...
2024-01-12 20:11:01.985 Error: TinyTUYA: (tinytuya) failed to load 'plugin.py', Python Path used was '/opt/domoticz/userdata/plugins/Domoticz-TinyTUYA-Plugin/:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.9/dist-packages'.
2024-01-12 20:11:01.987 Error: TinyTUYA: Traceback (most recent call last):
2024-01-12 20:11:01.987 Error: TinyTUYA: File "/opt/domoticz/userdata/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 60, in <module>
2024-01-12 20:11:01.987 Error: TinyTUYA: import tinytuya
2024-01-12 20:11:01.987 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/tinytuya/__init__.py", line 92, in <module>
2024-01-12 20:11:01.987 Error: TinyTUYA: from .core import *
2024-01-12 20:11:01.987 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/tinytuya/core.py", line 121, in <module>
2024-01-12 20:11:01.987 Error: TinyTUYA: raise ModuleNotFoundError('No crypto library found, please "pip install" cryptography, pycryptodome, or pyaes')
2024-01-12 20:11:01.987 Error: TinyTUYA: ModuleNotFoundError: No crypto library found, please "pip install" cryptography, pycryptodome, or pyaes
I figure this out later.
Nornal cryptography is also installed by Tinytuya...
sudo pip3 install cryptography
After instelling cryptography it works fine, thanks for the tip. But what about this log?
2024-01-13 07:57:34.125 TinyTUYA: No device data returned for Tuya. Trying again!
2024-01-13 07:57:34.691 TinyTUYA: Scanning for tuya devices on network...
If a new device comes along, is it added automatically?
TinyTUYA: No device data returned for Tuya. Trying again!
This is a loop that reads the basic info about the device from Tuya and store it in memory. it will try 10 times. You can see that info of you setup and run the debug_discovery.py in the tools directory. Function loaded at the start plugin and status every minute.
Scanning for tuya devices on network...
This will detect the ip-adress of the device and store in also in memory.
If a new device comes along, is it added automatically?
No, the plugin needs a restart to detect the new device, its is to reduce the calls to the Tuya server.
So what the plugin basically does is get the IP from 1 device and scan that IP-range for other devices?
And on/off triggers are done locally or using the Tuya server?
Yep indeed. At the moment no local control, the commands are complete different.
Cheers! I'll let this run for a while and see what happens the next time I add a device.
Just a thought: in my tests I was able to list all my devices straight from the Tuya server. Isn’t this easier than scanning the entire network? I was using the following: https://github.com/ground-creative/tuyapiphp
I used the built-in function in the Tinytuya module to keep it simple. The scanning time is about 15 seconds, and it only occurs at the start of the plugin. I know there's a lot to optimize in the plugin; I'm just a hobbyist, not a programmer! 😅
Just a thought, keep up the excellent work 👌🏻
The plugin still works fine, but gives the following timeout a couple of time per day:
Error: Tuya: handleThread: ('Connection aborted.', TimeoutError(110, 'Connection timed out')) line 224