Python Plugin: TUYA
Moderator: leecollings
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
Ha i see its version 1.0. Try this one version 1.3
https://github.com/Xenomes/Domoticz-TUYA-Plugin
https://github.com/Xenomes/Domoticz-TUYA-Plugin
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
-
- Posts: 8
- Joined: Wednesday 24 July 2019 14:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: TUYA
Hi, I cloned your code from github.
When I use grep, I see that it is now up-to-date:
(The files in your repo were .git, __pycache__, tools, plugin.py, README.md \\ Missing parts were: .vscode, tuyaha, .drone.yml, LICENSE, setup.py)
I still have a rgb color wheel and cannot seem to change the hue/color of the lights (by which I mean warmer/cooler colors of the white bulb).
Also, scenes are not available. I guess I'm doing something wrong. Would you be able tell what I need to change?
Thanks again for your support, really appreciate it!
When I use grep, I see that it is now up-to-date:
Since the plugin didn't work right away due to missing files, I copied the missing files from the original plugin. It now works again./plugins/Domoticz-TUYA-Plugin/plugin.py
<plugin key="tuya" name="TUYA" author="Wagner Oliveira" contributed="Xenomes" version="1.0.3" wikilink="http://www.domoticz.com/wiki/plugins/plugin.html" externallink="https://github.com/Xenomes/Domoticz-TUYA-Plugin.git">
# If Mode2 is not set (previous version didn't use it), set it
(The files in your repo were .git, __pycache__, tools, plugin.py, README.md \\ Missing parts were: .vscode, tuyaha, .drone.yml, LICENSE, setup.py)
I still have a rgb color wheel and cannot seem to change the hue/color of the lights (by which I mean warmer/cooler colors of the white bulb).
Also, scenes are not available. I guess I'm doing something wrong. Would you be able tell what I need to change?
Thanks again for your support, really appreciate it!
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
See the install instructions.Ruudhoevenaar wrote: ↑Tuesday 03 November 2020 8:06 Since the plugin didn't work right away due to missing files, I copied the missing files from the original plugin. It now works again.
(The files in your repo were .git, __pycache__, tools, plugin.py, README.md \\ Missing parts were: .vscode, tuyaha, .drone.yml, LICENSE, setup.py)
Delete the wrong device(s), go to 'Hardware' select the Tuya plugin and click update. Hardware detection must be on.Ruudhoevenaar wrote: ↑Tuesday 03 November 2020 8:06 I still have a rgb color wheel and cannot seem to change the hue/color of the lights (by which I mean warmer/cooler colors of the white bulb).
Also, scenes are not available. I guess I'm doing something wrong. Would you be able tell what I need to change?
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
-
- Posts: 8
- Joined: Wednesday 24 July 2019 14:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: TUYA
Removing the lights did the trick.
The plugin automatically refreshed the lights and the yellow-to-blue-wheel became available.
Thanks for the support!
The plugin automatically refreshed the lights and the yellow-to-blue-wheel became available.
Thanks for the support!
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
Nice to hear that it works!
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
-
- Posts: 2
- Joined: Tuesday 10 November 2020 16:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Netherlands
- Contact:
Re: Python Plugin: TUYA
Thanks for this plugin, I now can automate my Girier Smart Plugs via Domoticz.
Is it also possible to monitor the power consumption like in the Smart Life App?

Is it also possible to monitor the power consumption like in the Smart Life App?
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
Can you provide me with the json result of this script? debug_discovery.py
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
-
- Posts: 2
- Joined: Tuesday 10 November 2020 16:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Netherlands
- Contact:
Re: Python Plugin: TUYA
[/quote]
Can you provide me with the json result of this script? debug_discovery.py
[/quote]
Sure
Getting devices
Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': { 'devices': [ { 'data': {'online': True, 'state': True},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... kr6b_0.png',
'id': '54524532b4e62d5cd45a',
'name': 'Switch_1'},
{ 'data': {'online': True, 'state': True},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... kr6b_0.png',
'id': '58660042d8bfc0f1afb4',
'name': ' Switch_2'},
{ 'data': {'online': True, 'state': False},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... kr6b_0.png',
'id': '478803312cf43204a977',
'name': 'Switch_3'},
{ 'data': {},
'scenes': []}}
Can you provide me with the json result of this script? debug_discovery.py
[/quote]
Sure
Getting devices
Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': { 'devices': [ { 'data': {'online': True, 'state': True},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... kr6b_0.png',
'id': '54524532b4e62d5cd45a',
'name': 'Switch_1'},
{ 'data': {'online': True, 'state': True},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... kr6b_0.png',
'id': '58660042d8bfc0f1afb4',
'name': ' Switch_2'},
{ 'data': {'online': True, 'state': False},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... kr6b_0.png',
'id': '478803312cf43204a977',
'name': 'Switch_3'},
{ 'data': {},
'scenes': []}}
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
In the json there is no power consumption value returning. I will check the tuyaha library if there is some code for reading it. I will let you know.
Edit:
There in no reading tuyaha library in the, see https://github.com/PaulAnnekov/tuyaha/b ... /switch.py
Edit:
There in no reading tuyaha library in the, see https://github.com/PaulAnnekov/tuyaha/b ... /switch.py
Last edited by Xenomes on Monday 16 November 2020 8:41, edited 1 time in total.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
- TiXav
- Posts: 40
- Joined: Saturday 28 November 2015 22:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: France
- Contact:
Re: Python Plugin: TUYA
Xenomes
following the post in Re: Python Plugin still running after disabling in Hardware page @ viewtopic.php?f=65&t=34563
I do these modifications because I bought 2 RGB led strip controllers (CuisinePlan is one of them) and there is a mode colour but no brightness neither no color_temp, so I use them as switch even it could use them at least as dimmer
following the post in Re: Python Plugin still running after disabling in Hardware page @ viewtopic.php?f=65&t=34563
I do these modifications because I bought 2 RGB led strip controllers (CuisinePlan is one of them) and there is a mode colour but no brightness neither no color_temp, so I use them as switch even it could use them at least as dimmer

- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
That is strange, if you change setting in the used Tuya-App and rerun the debug_discovery.py script do you get other data fields in the JSON?
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
-
- Posts: 28
- Joined: Monday 25 January 2016 6:33
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Python Plugin: TUYA
Nice work. I do have an issue however with the plugin. I have RGBW Merkury lights and they show up in the tuya app as RGB, however in Domoticz they show up as on/off switches. I'll try to edit the plugin to log info about the bulbs and post back as to what I find out. But again thanks for the nice plugin.
I'd rather have a bottle in front of me than a frontal lobotomy
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
Can you provide me with the json result of this script? debug_discovery.pymoengiant wrote: ↑Wednesday 18 November 2020 3:05 Nice work. I do have an issue however with the plugin. I have RGBW Merkury lights and they show up in the tuya app as RGB, however in Domoticz they show up as on/off switches. I'll try to edit the plugin to log info about the bulbs and post back as to what I find out. But again thanks for the nice plugin.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
-
- Posts: 76
- Joined: Sunday 17 February 2019 15:01
- Target OS: NAS (Synology & others)
- Domoticz version: 4.10
- Contact:
Re: Python Plugin: TUYA
Chris12 wrote: ↑Friday 04 September 2020 12:28 I figured out that I need to be in the directory to install pip requests
After stopping and starting Domoticz on my Synology, the domoticz package won't start any more (it directly stops)Code: Select all
root@xxxxxx:~# cd /volume1/@appstore/py3k/usr/local/bin root@xxxxxx:/volume1/@appstore/py3k/usr/local/bin# sudo python3 pip3 install requests Collecting requests Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB) |████████████████████████████████| 61 kB 52 kB/s Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB) |████████████████████████████████| 127 kB 10.9 MB/s Collecting certifi>=2017.4.17 Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB) |████████████████████████████████| 156 kB 11.9 MB/s Collecting idna<3,>=2.5 Downloading idna-2.10-py2.py3-none-any.whl (58 kB) |████████████████████████████████| 58 kB 1.1 MB/s Collecting chardet<4,>=3.0.2 Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB) |████████████████████████████████| 133 kB 11.2 MB/s Installing collected packages: urllib3, certifi, idna, chardet, requests WARNING: The script chardetect is installed in '/volume1/@appstore/py3k/usr/local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed certifi-2020.6.20 chardet-3.0.4 idna-2.10 requests-2.24.0 urllib3-1.25.10 root@xxxxxx:/volume1/@appstore/py3k/usr/local/bin#
How can I unstall the above installed pip requests?
edit: this one was simple to find:
Now domoticz run fine again... but the smartplug has still the same error.Code: Select all
root@xxxxxx:/volume1/@appstore/py3k/usr/local/bin# sudo python3 pip3 uninstall requests Found existing installation: requests 2.24.0 Uninstalling requests-2.24.0: Would remove: /volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests-2.24.0.dist-info/* /volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/* Proceed (y/n)? y Successfully uninstalled requests-2.24.0 root@xxxxxx:/volume1/@appstore/py3k/usr/local/bin#
edit2:
When removing first the TUYA hardware already defined/created in domoticz, and then install the pip3 request
Domoticz keeps on running fine, after adding the TUYA hardware, domoticz is stopped and wont start again.
Had the same problems with installing the python packages. sudo pip3 requests did the trick, without python or python3 before pip.

Check my Domoticz tutorials, ESP8266 and Synology blog at https://www.twoenter.nl/blog
-
- Posts: 2
- Joined: Monday 01 August 2016 20:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: TUYA
Very nice works
This plugin work very well. i have 4 roller shutter switch and 3 scene
But i have a problem with 1 device he don't works with this plugin
I found a by-pass by using scene to control it, but isn't a good solution
The faulty device it-is a new 4th generation of roller shutter switch with new percent feature.
Can you help me to improve plugin to manage well this switch ?
You can find below the discovery log
the faulty device is "Volet Salon 1"
Got devices



This plugin work very well. i have 4 roller shutter switch and 3 scene
But i have a problem with 1 device he don't works with this plugin


The faulty device it-is a new 4th generation of roller shutter switch with new percent feature.
Can you help me to improve plugin to manage well this switch ?
You can find below the discovery log
the faulty device is "Volet Salon 1"
Got devices
- Spoiler: show
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
The strange thing is the 'tuyaha' report it as a switch. can you change the state of the device and run the debug_discovery.py again?
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
-
- Posts: 2
- Joined: Monday 01 August 2016 20:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: TUYA
Yes that is strange, I have tested to open and close and the status never change, it is always State = False.

With Smart Life application is work well, with some new options, percentage, child lock...
I'm wondering if it's not using a new, improved API version

Re: Python Plugin: TUYA
Hi @Xenomes
Thank you for working on this plugin.
I have recently acquired an Inkbird ITC-308-WIFI temperature controller. It reports temperature and allows the switching of heating and cooling based on a set point. I am using it for a Marine Fish Tank.
Below is a dump from your debug_discovery. The TUYA app allows me to set the units switchpoints and various settings but also reports the temp.
Getting devices
Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': { 'devices': [ { 'data': { 'current_temperature': 232,
'max_temper': 2120,
'min_temper': -400,
'online': True,
'state': 'false',
'temperature': 240},
'dev_type': 'climate',
'ha_type': 'climate',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... 2c7z_0.png',
'id': '428061235002916fca85',
'name': 'Marine Tank Thermostat'}],
'scenes': []}}
From what I can tell based on the setup of the unit the returned values are as per below. Temps are <value/10> so 232 is 23.2C.
'current_temperature': 232 = Current Temp
'max_temper': 2120, = Max Temp for Alarm
'min_temper': -400, = Min Temp for Alarm
'online': True, = Is the unit online
'state': 'false', = No idea, does not appear to change even if the unit goes into heating or cooling mode.
'temperature': 240 = Set point for the temp
Is it possible that you could look at integrating this device to report at minimum the reported temp and allow setting the set point? There are many things it does via the TUYA app like flag alarms over the max and min alarm set points but I am not sure how I can sniff this data.
Cheers
CV8R.
Thank you for working on this plugin.
I have recently acquired an Inkbird ITC-308-WIFI temperature controller. It reports temperature and allows the switching of heating and cooling based on a set point. I am using it for a Marine Fish Tank.
Below is a dump from your debug_discovery. The TUYA app allows me to set the units switchpoints and various settings but also reports the temp.
Getting devices
Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': { 'devices': [ { 'data': { 'current_temperature': 232,
'max_temper': 2120,
'min_temper': -400,
'online': True,
'state': 'false',
'temperature': 240},
'dev_type': 'climate',
'ha_type': 'climate',
'icon': 'https://images.tuyaeu.com/smart/icon/15 ... 2c7z_0.png',
'id': '428061235002916fca85',
'name': 'Marine Tank Thermostat'}],
'scenes': []}}
From what I can tell based on the setup of the unit the returned values are as per below. Temps are <value/10> so 232 is 23.2C.
'current_temperature': 232 = Current Temp
'max_temper': 2120, = Max Temp for Alarm
'min_temper': -400, = Min Temp for Alarm
'online': True, = Is the unit online
'state': 'false', = No idea, does not appear to change even if the unit goes into heating or cooling mode.
'temperature': 240 = Set point for the temp
Is it possible that you could look at integrating this device to report at minimum the reported temp and allow setting the set point? There are many things it does via the TUYA app like flag alarms over the max and min alarm set points but I am not sure how I can sniff this data.
Cheers
CV8R.
- Xenomes
- Posts: 402
- Joined: Tuesday 27 November 2018 19:05
- Target OS: Linux
- Domoticz version: 2024.7
- Location: Netherlands
- Contact:
Re: Python Plugin: TUYA
I created a issue on GitHubCV8R wrote: ↑Wednesday 02 December 2020 9:00 Is it possible that you could look at integrating this device to report at minimum the reported temp and allow setting the set point? There are many things it does via the TUYA app like flag alarms over the max and min alarm set points but I am not sure how I can sniff this data.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
Who is online
Users browsing this forum: Google [Bot] and 1 guest