Python Plugin: TUYA

Python and python framework

Moderator: leecollings

Post Reply
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

This are the versions on my machine.

Code: Select all

sudo pip3 install tuyaha requests -U
Requirement already up-to-date: tuyaha in /usr/local/lib/python3.7/dist-packages (0.0.10)
Requirement already up-to-date: requests in /usr/local/lib/python3.7/dist-packages (2.25.1)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests) (2.10)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests) (2020.11.8)
Requirement already satisfied, skipping upgrade: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests) (1.26.2)
Requirement already satisfied, skipping upgrade: chardet<5,>=3.0.2 in /usr/lib/python3/dist-packages (from requests) (3.0.4)
I see a path and python difference in you screen shot.
2021-02-01 21_02_44-Clipboard.png
2021-02-01 21_02_44-Clipboard.png (18.27 KiB) Viewed 2093 times
Looks like that requests is installed on a older python version, I don't know the solution. You can try uninstall and reinstall it, on you own risk 😅.

Code: Select all

sudo pip3 uninstall requests
sudo pip3 install requests
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
lolomin
Posts: 21
Joined: Sunday 11 October 2015 16:48
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by lolomin »

Hi,

Same problem as the one Afterburner described with Smart Life and a LIDL/Silvercrest light :

Below is the output of debug_discovery with token replaced by XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX :

[root@cygnus tools]# python3 debug_discovery.py
Getting credentials
Got credentials
{ 'access_token': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'expires_in': 864000,
'refresh_token': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'token_type': 'bearer'}
Getting devices
Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': {'devices': [], 'scenes': []}}

So it seems there is no devices/data though the plugin but everything is working well through Smart Life app ?
At your disposal to do every debug you need :)
Thanks !

Regards,

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

Re: Python Plugin: TUYA

Post by Xenomes »

lolomin wrote: Friday 05 February 2021 19:46 'payload': {'devices': [], 'scenes': []}}
As aspected there is no device info coming from the Tuya api. The only thing you can try is creating a scene and test if that control you device. Scene have only on/off control in the plug-in.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
lolomin
Posts: 21
Joined: Sunday 11 October 2015 16:48
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by lolomin »

Thanks for your answer, tried :
- to switch to a tuya account after reseting gateway and device : NOK, still no devices
- to add a scene and run again debug_discovery.py : NOK, still no devices, no scenes

Does it mean these devices are unmanageable through this plugin ?

Regards,

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

Re: Python Plugin: TUYA

Post by Xenomes »

lolomin wrote: Friday 05 February 2021 20:17 Does it mean these devices are unmanageable through this plugin ?
Yes indeed Tuya has to add the support to the API they provide. See link developer tuyaha library https://github.com/PaulAnnekov/tuyaha#m ... hould-i-do
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
Afterburner
Posts: 10
Joined: Wednesday 26 February 2020 17:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Afterburner »

Xenomes,

Related tot my requests issue, I renamed the one in Pyton3, installed the latest version in Python3.8, restarted Domoticz removed and reinstalled Tuya in the HW list. No effect. So appearently I have a structural problem in my setup or Tuya API is not supporting Lidl Home stuff. Thanks for supporting. For now I will look for other methods to work with this Zigbee devices.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Python Plugin: TUYA

Post by EdwinK »

I just noticed this in the error-log:

Code: Select all

 Python Plugin System: (Tuya) handleThread: HTTPSConnectionPool(host='px1.tuyaeu.com', port=443): Max retries exceeded with url: /homeassistant/skill (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x61852cd0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) line 185
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
HJ82
Posts: 1
Joined: Monday 01 March 2021 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by HJ82 »

Hello,

When i use the imported scene's from the tuya app in domotics it just works fine...
The tuya scene plays like i wanted it to.

But somehow the swiches in domoticz are not updated.
When i open the tuya app the status of the switches are updated to the correct status.

Am i doing something wrong?

Thnx a lot
Laurentd40
Posts: 1
Joined: Thursday 04 March 2021 14:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: Python Plugin: TUYA

Post by Laurentd40 »

Hello,

I've installed the Xenomes plugin for Tuya without problem and get my devices and scenes fron SmartLife app.
Currently I mainly have Curtain switches.
In the plugin they are correctly imported from 'cover' Tuya type to Domoticz Light/Switch-Blinds.
But it seems that the states is not correctly handled :
- states coming from my devices from Tuya API are 1 or 2.
- In the script, it seems that the plugin manage only 0/1 states (for all type of devices) during regular updates. So it always change to 1/On.

I've succeeded to add a local ugly patch to correct this but I would like to know :
- if I'm the only one in that case
- if I misunderstand the state management

Thank you in advance
janss028
Posts: 8
Joined: Monday 01 February 2021 19:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by janss028 »

Hi,
I using several wallplugs in the tuya app and connect them with tuyaha plugin (domoticz/plugins/tuyaha) to domoticz. This works fine.
Now I have 2 LSC moving sensors. I connect them to the tuya app and so far so good. I receive notifications if there is movements.

The problem is that I don't see these sensors in domoticz. Can someone help me?

Best Regards,
Ron
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

janss028 wrote: Thursday 04 March 2021 22:36 The problem is that I don't see these sensors in domoticz. Can someone help me?
Can you provide me with the json result of this script? debug_discovery.py
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

janss028 wrote: Thursday 04 March 2021 22:36 The problem is that I don't see these sensors in domoticz. Can someone help me?
Thanks for the PM, the json give no information a about the sensors, so there is data to work from.
The only thing you can do is send a mail to the Tuya Api department as mention on the site of the creator of the tuyaha
https://github.com/PaulAnnekov/tuyaha#m ... hould-i-do
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

Got yesterday my ledstrip rgb from aliexpress :) Add it in Tuya app, installed the script in domoticz.

He added the ledstrip but when i change color on rgb i get the following error, do i miss something or ?

Code: Select all

2021-03-07 11:11:19.797 Error: (Tuya) 'onCommand' failed 'TypeError':'int() argument must be a string, a bytes-like object or a number, not 'NoneType''.
2021-03-07 11:11:19.797 Error: (Tuya) ----> Line 250 in '/home/pi/domoticz/plugins/tuyaha/plugin.py', function onCommand
2021-03-07 11:11:19.797 Error: (Tuya) ----> Line 143 in '/home/pi/domoticz/plugins/tuyaha/plugin.py', function onCommand
2021-03-07 11:11:19.797 Error: (Tuya) ----> Line 79 in '/home/pi/domoticz/plugins/tuyaha/tuyaha/devices/light.py', function set_color

Code: Select all

pi@Domoticz:~/domoticz/plugins/tuyaha/tuyaha$ sudo pip3 show tuyaha
Name: tuyaha
Version: 0.0.10
Summary: A Python library that implements a Tuya API endpoint that was specially designed for Home Assistant
Home-page: https://github.com/PaulAnnekov/tuyaha
Author: Pavlo Annekov and original Tuya authors
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.6/dist-packages
Requires:

Code: Select all

2021-03-07 11:41:10.931 Status: Domoticz V2020.2 (build 12106) (c)2012-2020 GizMoCuz
2021-03-07 11:41:10.931 Status: Build Hash: b08d17c2d-modified, Date: 2020-05-29 09:01:13
2021-03-07 11:41:10.932 Status: Startup Path: /home/pi/domoticz/
2021-03-07 11:41:10.954 Status: PluginSystem: Started, Python version '3.6.9'.
2021-03-07 11:41:10.956 Status: WebServer(HTTP) started on address: :: with port 9090
2021-03-07 11:41:10.958 Status: WebServer(SSL) started on address: :: with port 443
2021-03-07 11:41:10.958 Status: Camera: settings (re)loaded
2021-03-07 11:41:10.959 Status: TCPServer: shared server started...
2021-03-07 11:41:10.959 Status: RxQueue: queue worker started...
2021-03-07 11:41:12.959 Status: Hardware Monitor: Started
2021-03-07 11:41:12.971 Status: RFXCOM: Worker started...
2021-03-07 11:41:12.971 Status: P1MeterTCP: attempt connect to 192.168.0.6:8899
2021-03-07 11:41:12.972 Status: XiaomiGateway (ID=13): Delaying worker startup...
2021-03-07 11:41:12.972 Status: P1MeterTCP: connected to: 192.168.0.6:8899
2021-03-07 11:41:13.944 Status: P1 Smart Meter: Meter reports as DSMR 4.2
2021-03-07 11:41:14.324 Status: P1 Smart Meter: Found gas meter on M-Bus channel 1
2021-03-07 11:41:15.939 Status: RFXCOM: Using serial port: /dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1YQEWJY-if00-port0
2021-03-07 11:41:17.972 Status: XiaomiGateway (ID=13): Selected as main Gateway
2021-03-07 11:41:17.972 Status: XiaomiGateway (ID=13): Worker started...
2021-03-07 11:41:17.972 Status: (Buienradar) Started.
2021-03-07 11:41:17.972 Status: XiaomiGateway (ID=13): Using 192.168.0.5 for local IP address.
2021-03-07 11:41:17.972 Status: (Led Keuken) Started.
2021-03-07 11:41:17.972 Status: XiaomiGateway (ID=17): Delaying worker startup...
2021-03-07 11:41:17.974 Status: XiaomiGateway: RGB Gateway Detected
2021-03-07 11:41:18.973 Status: MQTT: Connecting to 192.168.0.5:1883
2021-03-07 11:41:19.174 Status: MQTT: connected to: 192.168.0.5:1883
2021-03-07 11:41:19.374 Status: MQTT: Subscribed
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

Vomera wrote: Sunday 07 March 2021 11:42 He added the ledstrip but when i change color on rgb i get the following error, do i miss something or ?
Can you provide me with the json result of this script? debug_discovery.py is located in the tools directory
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

Xenomes wrote: Sunday 07 March 2021 14:40
Vomera wrote: Sunday 07 March 2021 11:42 He added the ledstrip but when i change color on rgb i get the following error, do i miss something or ?
Can you provide me with the json result of this script? debug_discovery.py is located in the tools directory
Send you a pm :)
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Python Plugin: TUYA

Post by simon_rb »

I bought a switch because of this plugin, so thank you :)

It’s all working, its worth nothing that it didn’t like my password as it had a - in it. Once changed to just numbers and letters it worked fine.

It takes about 5 mins for changes to reflect in Domoticz if a switch is physically switched or switched using the Smart Life app. Not really an issues if thats the usual delay. Just checking my setup is correct.

Cheers!
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

Vomera wrote: Sunday 07 March 2021 21:17
Xenomes wrote: Sunday 07 March 2021 14:40
Vomera wrote: Sunday 07 March 2021 11:42 He added the ledstrip but when i change color on rgb i get the following error, do i miss something or ?
Can you provide me with the json result of this script? debug_discovery.py is located in the tools directory
Send you a pm :)
Sended you again a pm, could you use the information i provided ?
manjh
Posts: 708
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 am completely new to this plugin, so it is very likely that I made a mistake somewhere. :shock:
Having said that, this is what happened.

Today I bought two LSC Smart LED lamps, they are warm/cool white lamps.
In stead of the recommended LSC SMart Home app, I picked the Tuya app because it is supported by the Tuya plugin.
First installed the app, and added the two lamps. Works OK.
Then installed the Tuya app, restarted Domoticz and added a hardware line for Tuya, providing userid/pw of the app.

After a little while, lamps show up in Domoticz. I enabled them and found the icons.
It looks OK: I can switch the lamps on/off, and can modify the dimming level.
But there is no way to change the color temperature. In the devices tab of Domoticz, the lamps show up as RGB, which is wrong.
What did I do wrong, and how can I correct?
Hans
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

manjh wrote: Wednesday 17 March 2021 22:18 I am completely new to this plugin, so it is very likely that I made a mistake somewhere. :shock:
Having said that, this is what happened.

Today I bought two LSC Smart LED lamps, they are warm/cool white lamps.
In stead of the recommended LSC SMart Home app, I picked the Tuya app because it is supported by the Tuya plugin.
First installed the app, and added the two lamps. Works OK.
Then installed the Tuya app, restarted Domoticz and added a hardware line for Tuya, providing userid/pw of the app.

After a little while, lamps show up in Domoticz. I enabled them and found the icons.
It looks OK: I can switch the lamps on/off, and can modify the dimming level.
But there is no way to change the color temperature. In the devices tab of Domoticz, the lamps show up as RGB, which is wrong.
What did I do wrong, and how can I correct?
I guess there are some problems with the plugin because i have the same kind of problem, the writer of the scrip is watching to it :)
manjh
Posts: 708
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 »

Vomera wrote: Wednesday 17 March 2021 22:26
manjh wrote: Wednesday 17 March 2021 22:18 I am completely new to this plugin, so it is very likely that I made a mistake somewhere. :shock:
Having said that, this is what happened.

Today I bought two LSC Smart LED lamps, they are warm/cool white lamps.
In stead of the recommended LSC SMart Home app, I picked the Tuya app because it is supported by the Tuya plugin.
First installed the app, and added the two lamps. Works OK.
Then installed the Tuya app, restarted Domoticz and added a hardware line for Tuya, providing userid/pw of the app.

After a little while, lamps show up in Domoticz. I enabled them and found the icons.
It looks OK: I can switch the lamps on/off, and can modify the dimming level.
But there is no way to change the color temperature. In the devices tab of Domoticz, the lamps show up as RGB, which is wrong.
What did I do wrong, and how can I correct?
I guess there are some problems with the plugin because i have the same kind of problem, the writer of the scrip is watching to it :)
Ah, good. Let me know if I can help.
Would be great if this can be solved, the lamps are cheap (€3,95 at the local Action store!), and I will buy more once everything is working OK!
Hans
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests