Python Plugin: TUYA

Python and python framework

Moderator: leecollings

User avatar
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post 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.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2025.1 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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?
Hans
User avatar
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post 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.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2025.1 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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"... :?
Hans
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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?
Hans
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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. :D
Hans
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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.
Hans
User avatar
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post 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.

Code: Select all

sudo pip3 install tinytuya
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2025.1 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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'
Hans
User avatar
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

The error say that 'tinytuya' not is installed. Are you running standalone or with the service or even in docker?
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2025.1 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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.
Hans
User avatar
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post 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.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2025.1 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
User avatar
heggink
Posts: 979
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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!
Hans
User avatar
waltervl
Posts: 5844
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
heggink
Posts: 979
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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!
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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?
Hans
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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?
Hans
User avatar
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post 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.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2025.1 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post 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... :(
Hans
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest