Page 25 of 26
Re: Python Plugin: TUYA
Posted: Saturday 26 October 2024 18:54
by Xenomes
manjh wrote: ↑Saturday 26 October 2024 11:51
I have been using TUYA plugin version 1.0.13 for quite some time now, it used to work OK but recently I find it non-responding. No apparent error code, just "not working".
I have tried to disable and then enable the plugin, but that sometimes fails and locksup Domoticz.
The solution that works OK is to log in to the Pi, and restart the Domoticz service.
Any clues?
I have thought about migrating to another plugin (tinyTuya??), but am a bit worried about the migration path. Would I lose all devices, and then manually have to re-install?
I just tested the old plugin, and the Tuya API is still working. There is no need to migrate between the plugins; you can run them together and replace the devices in your scripts, and so on.
Re: Python Plugin: TUYA
Posted: Tuesday 29 October 2024 7:58
by manjh
OK, thanks.
In the mean time, I've "reneweded" my password in the Tuya cloud, not sure if that will cure the problems.
Also tried to get TinyTuya running. Installing is not a problem, but when I log in to the Tuya cloud and open my project, I cannot see any devices. My Tuya app shows the whole list, and in Domoticz I can see them as well. Am I looking in the wrong place to find a device ID?
Re: Python Plugin: TUYA
Posted: Tuesday 29 October 2024 21:55
by Xenomes
manjh wrote: ↑Tuesday 29 October 2024 7:58
Am I looking in the wrong place to find a device ID?
Go to iot.tuya.com => Cloud => open Project => Devices
Device ID are listed there, you need only one.
Re: Python Plugin: TUYA
Posted: Wednesday 30 October 2024 7:32
by manjh
Xenomes wrote: ↑Tuesday 29 October 2024 21:55
manjh wrote: ↑Tuesday 29 October 2024 7:58
Am I looking in the wrong place to find a device ID?
Go to iot.tuya.com => Cloud => open Project => Devices
Device ID are listed there, you need only one.
I get an empty list. "no data found"...

Re: Python Plugin: TUYA
Posted: Wednesday 30 October 2024 19:33
by manjh
Just wondering. When I look at the "old" Tuya plugin, I only need the userid/PW for app access, and all devices are detected.
With the TinyTuya app I need a device ID. Why the difference?
Re: Python Plugin: TUYA
Posted: Wednesday 30 October 2024 19:35
by manjh
manjh wrote: ↑Wednesday 30 October 2024 7:32
Xenomes wrote: ↑Tuesday 29 October 2024 21:55
manjh wrote: ↑Tuesday 29 October 2024 7:58
Am I looking in the wrong place to find a device ID?
Go to iot.tuya.com => Cloud => open Project => Devices
Device ID are listed there, you need only one.
I get an empty list. "no data found"...
Got it. For some strange reason I must have created the project using Central European Data Center, in stead of Western. Once I changed that, I can now see my devices.

Re: Python Plugin: TUYA
Posted: Wednesday 30 October 2024 19:45
by manjh
So I went back and installed TinyTuya as per instructions.
Installation shows on Pi:
Code: Select all
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
The Domoticz log shows me:
Code: Select all
2024-10-30 19:41:36.487 TinyTuya: Worker thread started.
2024-10-30 19:41:36.487 Status: TinyTuya: Entering work loop.
2024-10-30 19:41:36.487 Status: TinyTuya: Started.
2024-10-30 19:41:36.829 Error: TinyTuya: (tinytuya) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2024-10-30 19:41:36.839 Error: TinyTuya: Traceback (most recent call last):
2024-10-30 19:41:36.839 Error: TinyTuya: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 67, in <module>
2024-10-30 19:41:36.839 Error: TinyTuya: import tinytuya
2024-10-30 19:41:36.839 Error: TinyTuya: ModuleNotFoundError: No module named 'tinytuya'
Is that related to the OS level? I am running Buster.
Re: Python Plugin: TUYA
Posted: Wednesday 30 October 2024 20:19
by Xenomes
manjh wrote: ↑Wednesday 30 October 2024 19:45
So I went back and installed TinyTuya as per instructions.
Installation shows on Pi:
Code: Select all
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
I never see this error installing the Tinytuya, what do you get if you install tinytuya only.
Re: Python Plugin: TUYA
Posted: Thursday 31 October 2024 8:05
by manjh
When I install TinyTuya only, it only gives me some remarks like "request already satisfied"...
Restarted Domoticz again, and enabled the plugin, gives me:
Code: Select all
2024-10-31 08:03:38.187 TinyTuya: Worker thread started.
2024-10-31 08:03:38.187 Status: TinyTuya: Entering work loop.
2024-10-31 08:03:38.187 Status: TinyTuya: Started.
2024-10-31 08:03:38.311 Error: TinyTuya: (tinytuya) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2024-10-31 08:03:38.322 Error: TinyTuya: Traceback (most recent call last):
2024-10-31 08:03:38.322 Error: TinyTuya: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 67, in <module>
2024-10-31 08:03:38.322 Error: TinyTuya: import tinytuya
2024-10-31 08:03:38.322 Error: TinyTuya: ModuleNotFoundError: No module named 'tinytuya'
Re: Python Plugin: TUYA
Posted: Thursday 31 October 2024 14:35
by Xenomes
The error say that 'tinytuya' not is installed. Are you running standalone or with the service or even in docker?
Re: Python Plugin: TUYA
Posted: Thursday 31 October 2024 20:51
by manjh
I'm not using a docker.
Not sure what you mean by standalone or service. I'm running Domoticz on a Pi4, installed it as per the instructions in the Wiki.
Installed TinyTuya, again as per the instructions.
Re: Python Plugin: TUYA
Posted: Thursday 31 October 2024 21:03
by Xenomes
If you start Domoticz with 'sudo systemctl start domoticz.service' you run it as a Service.
Starting Domoticz './domoticz -www 8085 -sslwww 0' standalone/manual used for testing, you also need to install tinytuya in the user environment (without the sudo) services is running under the superuser.
Re: Python Plugin: TUYA
Posted: Friday 01 November 2024 10:21
by heggink
Off topic but I thought I would sollicit anyway: I saw the author (xeno..) work on a plugin using the local api. There is a node red implementation for the local api which I am now using. Together with a little logic (with help from @gizmocuz) that creates the HA-autodiscovery devices, it works really well. I use it to control both a heater and an IR panel. Using the local api, I am no longer dependent on a cloud service.
Happy to share if anyone is interested.
Re: Python Plugin: TUYA
Posted: Friday 01 November 2024 18:24
by manjh
heggink wrote: ↑Friday 01 November 2024 10:21
Off topic but I thought I would sollicit anyway: I saw the author (xeno..) work on a plugin using the local api. There is a node red implementation for the local api which I am now using. Together with a little logic (with help from @gizmocuz) that creates the HA-autodiscovery devices, it works really well. I use it to control both a heater and an IR panel. Using the local api, I am no longer dependent on a cloud service.
Happy to share if anyone is interested.
Yes, interested!
Re: Python Plugin: TUYA
Posted: Friday 01 November 2024 18:44
by waltervl
The beta plugin for local tuya is here
https://github.com/Xenomes/Domoticz-Tin ... cal-Plugin
Perhaps easier to improve that then go into another route with MQTT AD and Node-Red.
Re: Python Plugin: TUYA
Posted: Saturday 02 November 2024 7:56
by heggink
I'll write a topic about this under the mqtt-ad section
manjh wrote: ↑Friday 01 November 2024 18:24
heggink wrote: ↑Friday 01 November 2024 10:21
Off topic but I thought I would sollicit anyway: I saw the author (xeno..) work on a plugin using the local api. There is a node red implementation for the local api which I am now using. Together with a little logic (with help from @gizmocuz) that creates the HA-autodiscovery devices, it works really well. I use it to control both a heater and an IR panel. Using the local api, I am no longer dependent on a cloud service.
Happy to share if anyone is interested.
Yes, interested!
Re: Python Plugin: TUYA
Posted: Saturday 02 November 2024 13:33
by manjh
viewtopic.php?f=82&t=42805
Here you go.
heggink wrote: ↑Saturday 02 November 2024 7:56
I'll write a topic about this under the mqtt-ad section
OK, that would be great. Can you post a link here to the new topic?
Re: Python Plugin: TUYA
Posted: Saturday 02 November 2024 13:37
by manjh
I now own about 15 smart-switches and I can switch them on/off from Domoticz.
But most of these switches also have power-monitoring on board, and I have been unable to access the stored information from Domoticz.
When I access them via the Tuya app, there is quite a lot of useful info.
Is there a way to pull that info into Domoticz?
Re: Python Plugin: TUYA
Posted: Saturday 02 November 2024 16:53
by Xenomes
manjh wrote: ↑Saturday 02 November 2024 13:37
I now own about 15 smart-switches and I can switch them on/off from Domoticz.
But most of these switches also have power-monitoring on board, and I have been unable to access the stored information from Domoticz.
When I access them via the Tuya app, there is quite a lot of useful info.
Is there a way to pull that info into Domoticz?
That data isn’t shared by the tinytuya module, and I don’t think it’s shared from Tuya to tinytuya either. You could update the device in Domoticz, and it should refresh, but due to a calculation in place, there will be some drift over time.
Re: Python Plugin: TUYA
Posted: Saturday 02 November 2024 17:14
by manjh
Xenomes wrote: ↑Saturday 02 November 2024 16:53
manjh wrote: ↑Saturday 02 November 2024 13:37
I now own about 15 smart-switches and I can switch them on/off from Domoticz.
But most of these switches also have power-monitoring on board, and I have been unable to access the stored information from Domoticz.
When I access them via the Tuya app, there is quite a lot of useful info.
Is there a way to pull that info into Domoticz?
That data isn’t shared by the tinytuya module, and I don’t think it’s shared from Tuya to tinytuya either. You could update the device in Domoticz, and it should refresh, but due to a calculation in place, there will be some drift over time.
OK, thanks. There is quite a bit of info there, but if it isn't shared: tough luck...
