Python Plugin: TUYA

Python and python framework

Moderator: leecollings

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
EdwinK wrote: Wednesday 14 April 2021 22:04 Aaaaaaand....

it's back.
2021-04-14 22:01:32.027 Status: Tuya: (Tuya) Initialized version 1.0.6, author 'Wagner Oliveira'
2021-04-14 22:01:32.734 Error: Tuya: (Tuya) handleThread: login rate limited line 195
Just the second after restarting the plugin.
This a error from the Tuya api, the restart trigger a second login in a time period of 60 sec. I have a idea, I don't if it will work.
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
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 »

What is the best way to switch a Tuya lamp from LUA? On/off and color temp?
Hans
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 »

manjh wrote: Friday 16 April 2021 9:27 What is the best way to switch a Tuya lamp from LUA? On/off and color temp?
I use DzVents setColorBrightness(r, g, b, br, cw, ww, m, t)
https://www.domoticz.com/wiki/DzVents:_ ... .2FApplamp
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 »

EdwinK wrote: Wednesday 14 April 2021 22:04
Xenomes wrote: Wednesday 14 April 2021 22:11 This a error from the Tuya api, the restart trigger a second login in a time period of 60 sec. I have a idea, I don't if it will work.
Made a new update there is now a start-up time out for 60 seconds to prevent the login in the same minute.
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
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 »

Xenomes wrote: Friday 16 April 2021 20:43
EdwinK wrote: Wednesday 14 April 2021 22:04
Xenomes wrote: Wednesday 14 April 2021 22:11 This a error from the Tuya api, the restart trigger a second login in a time period of 60 sec. I have a idea, I don't if it will work.
Made a new update there is now a start-up time out for 60 seconds to prevent the login in the same minute.

Thanks. Will update and see ;)
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
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 »

Updated to version 1.0.7, and now the error is:

2021-04-16 22:06:28.657 Error: Tuya: (Tuya) handleThread: Expecting value: line 1 column 1 (char 0) line 207
2021-04-16 22:06:37.243 Error: Tuya: (Tuya) handleThread: Expecting value: line 1 column 1 (char 0) line 207
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
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 »

EdwinK wrote: Friday 16 April 2021 22:18 Updated to version 1.0.7, and now the error is:

2021-04-16 22:06:28.657 Error: Tuya: (Tuya) handleThread: Expecting value: line 1 column 1 (char 0) line 207
2021-04-16 22:06:37.243 Error: Tuya: (Tuya) handleThread: Expecting value: line 1 column 1 (char 0) line 207
I can't recreate your error, change a command hopefully it will fix this error.
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
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 »

At the moment it isn't working at all :(
2021-04-17 20:57:42.154 Tuya: (Tuya) Waiting 60 seconds to connect TuyaApi login timeout
2021-04-17 20:57:48.895 Status: User: Admin (IP: 192.168.0.14) initiated a switch command (1039/Tuya - LED Strip RGB+W/On)
2021-04-17 20:58:16.088 Status: User: Admin (IP: 192.168.0.14) initiated a switch command (1039/Tuya - LED Strip RGB+W/On)
2021-04-17 20:58:36.160 Error: Tuya hardware (52) thread seems to have ended unexpectedly
2021-04-17 20:58:42.214 Tuya: (Tuya) TUYA plugin started
2021-04-17 20:58:42.214 Tuya: (Tuya) Debug logging mask set to: PYTHON CONNECTION
2021-04-17 20:58:42.214 Tuya: (Tuya) 'HardwareID':'52'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'HomeFolder':'/home/pi/domoticz/plugins/TUYA/'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'StartupFolder':'/home/pi/domoticz/'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'UserDataFolder':'/home/pi/domoticz/'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'Database':'/home/pi/domoticz/domoticz.db'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'Language':'en'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'Version':'1.0.6'
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
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 »

It seemst that the connector in the LED-string has brokken, so it might be that that is the problem. Not having another device to try it with.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
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 »

EdwinK wrote: Saturday 17 April 2021 20:59 At the moment it isn't working at all :(
2021-04-17 20:57:42.154 Tuya: (Tuya) Waiting 60 seconds to connect TuyaApi login timeout
2021-04-17 20:57:48.895 Status: User: Admin (IP: 192.168.0.14) initiated a switch command (1039/Tuya - LED Strip RGB+W/On)
2021-04-17 20:58:16.088 Status: User: Admin (IP: 192.168.0.14) initiated a switch command (1039/Tuya - LED Strip RGB+W/On)
2021-04-17 20:58:36.160 Error: Tuya hardware (52) thread seems to have ended unexpectedly
2021-04-17 20:58:42.214 Tuya: (Tuya) TUYA plugin started
2021-04-17 20:58:42.214 Tuya: (Tuya) Debug logging mask set to: PYTHON CONNECTION
2021-04-17 20:58:42.214 Tuya: (Tuya) 'HardwareID':'52'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'HomeFolder':'/home/pi/domoticz/plugins/TUYA/'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'StartupFolder':'/home/pi/domoticz/'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'UserDataFolder':'/home/pi/domoticz/'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'Database':'/home/pi/domoticz/domoticz.db'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'Language':'en'
2021-04-17 20:58:42.214 Tuya: (Tuya) 'Version':'1.0.6'
These are normal startup messages. Ps. you are on version 1.0.6 or didn't restart Domoticz after update.
EdwinK wrote: Saturday 17 April 2021 21:12 It seemst that the connector in the LED-string has brokken, so it might be that that is the problem. Not having another device to try it with.
That's not good ...
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
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 »

It said on the the hardware ta it is version 1.0.7 but since I have no Tuya stuff at the moment, cant' test it
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
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 »

Xenomes wrote: Friday 16 April 2021 20:40
manjh wrote: Friday 16 April 2021 9:27 What is the best way to switch a Tuya lamp from LUA? On/off and color temp?
I use DzVents setColorBrightness(r, g, b, br, cw, ww, m, t)
https://www.domoticz.com/wiki/DzVents:_ ... .2FApplamp
Good. That way I can set all lamps to the same color temperature. The color picker wheel just doesn't allow that kind of precision.
Hans
MacJL
Posts: 51
Joined: Tuesday 22 April 2014 22:17
Target OS: OS X
Domoticz version: Beta
Location: France
Contact:

Re: Python Plugin: TUYA

Post by MacJL »

Hello,

I have un problem while running this plug-in :

Code: Select all

2021-04-22 12:23:52.523 Tuya: (Tuya) TUYA plugin started
2021-04-22 12:23:52.523 Tuya: (Tuya) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE
2021-04-22 12:23:52.523 Tuya: (Tuya) 'HardwareID':'15'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'HomeFolder':'/domoticz/plugins/Domoticz-TUYA-Plugin/'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'StartupFolder':'/domoticz/'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'UserDataFolder':'/domoticz/'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'Database':'/config/domoticz.db'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'Language':'fr'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'Version':'1.0.7b'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'Author':'Wagner Oliveira'
2021-04-22 12:23:52.523 Tuya: (Tuya) 'Name':'Tuya'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'Port':'0'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'Username':'******@******.***'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'Password':'*************'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'Key':'tuya'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'Mode1':'33'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'Mode2':'tuya'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'Mode6':'-1'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'DomoticzVersion':'2021.1'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'DomoticzHash':'8547c5b7e'
2021-04-22 12:23:52.524 Tuya: (Tuya) 'DomoticzBuildTime':'2021-04-17 17:29:11'
2021-04-22 12:23:52.524 Tuya: (Tuya) Device count: 0
2021-04-22 12:23:52.525 Tuya: (Tuya) in handlethread
2021-04-22 12:23:52.577 Tuya: (Tuya) Pushing 'onHeartbeatCallback' on to queue
2021-04-22 12:23:52.627 (Tuya) Processing 'onHeartbeatCallback' message
2021-04-22 12:23:52.687 Tuya: (Tuya) Calling message handler 'onHeartbeat'.
2021-04-22 12:23:52.687 Tuya: (Tuya) onHeartbeat called time=1619087032.6875422
2021-04-22 12:23:52.687 Tuya: (Tuya) in handlethread
2021-04-22 12:23:53.915 Error: Tuya: (Tuya) handleThread: Expecting value: line 1 column 1 (char 0) line 207 
I'm running domoticz in a container, so with a minimal OS. Is there something missing?
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 »

MacJL wrote: Thursday 22 April 2021 12:27 Hello,

I have un problem while running this plug-in :

I'm running domoticz in a container, so with a minimal OS. Is there something missing?
Thanks for the include log, I saw the problem and create a fix. Please check version 1.0.8
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
MacJL
Posts: 51
Joined: Tuesday 22 April 2014 22:17
Target OS: OS X
Domoticz version: Beta
Location: France
Contact:

Re: Python Plugin: TUYA

Post by MacJL »

Xenomes wrote: Thursday 22 April 2021 21:22 Thanks for the include log, I saw the problem and create a fix. Please check version 1.0.8
Thank you. No more errors anymore!

But I don’t see my Tuya device in Domoticz. Device count stay at 0. I have a eMylo EAI-90 that I can control with Tuya App.
How can I check what is happening?
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 »

MacJL wrote: Thursday 22 April 2021 22:02
Xenomes wrote: Thursday 22 April 2021 21:22 Thanks for the include log, I saw the problem and create a fix. Please check version 1.0.8
Thank you. No more errors anymore!

But I don’t see my Tuya device in Domoticz. Device count stay at 0. I have a eMylo EAI-90 that I can control with Tuya App.
How can I check what is happening?
You can run the debug_discovery.py from the tools directory it will show if your device is detected by the tuyaapi.
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
MacJL
Posts: 51
Joined: Tuesday 22 April 2014 22:17
Target OS: OS X
Domoticz version: Beta
Location: France
Contact:

Re: Python Plugin: TUYA

Post by MacJL »

Here is the result :

Code: Select all

 Getting credentials
Got credentials
{   'access_token': 'EUxxxxx',
    'expires_in': 864000,
    'refresh_token': 'EUxxx',
    'token_type': 'bearer'}
Getting devices
Got devices
{   'header': {'code': 'SUCCESS', 'payloadVersion': 1},
    'payload': {'devices': [], 'scenes': []}}
!!! NOW REMOVE THIS FILE, SO YOUR CREDENTIALS (username, password) WON'T LEAK !!!
Does it mean the device is not supported ? Is that on Tuyaapi side, or Tuya side?
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 »

MacJL wrote: Thursday 22 April 2021 22:28 Here is the result :

Code: Select all

 Getting credentials
Got credentials
{   'access_token': 'EUxxxxx',
    'expires_in': 864000,
    'refresh_token': 'EUxxx',
    'token_type': 'bearer'}
Getting devices
Got devices
{   'header': {'code': 'SUCCESS', 'payloadVersion': 1},
    'payload': {'devices': [], 'scenes': []}}
!!! NOW REMOVE THIS FILE, SO YOUR CREDENTIALS (username, password) WON'T LEAK !!!
Does it mean the device is not supported ? Is that on Tuyaapi side, or Tuya side?
Sorry the device is not supported by api of Tuya. Result devices': [],
The only thing what you can do is https://github.com/Xenomes/Domoticz-TUY ... 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
MacJL
Posts: 51
Joined: Tuesday 22 April 2014 22:17
Target OS: OS X
Domoticz version: Beta
Location: France
Contact:

Re: Python Plugin: TUYA

Post by MacJL »

Xenomes wrote: Thursday 22 April 2021 22:44 Sorry the device is not supported by api of Tuya. Result devices': [],
The only thing what you can do is https://github.com/Xenomes/Domoticz-TUY ... hould-i-do
Thank you for your help.
What’s frustrating, is that I can control this device with the tuyaapi project. Does someone know if there is an other maintained Domoticz plug-in that use this API instead of tuyaha ?
MacJL
Posts: 51
Joined: Tuesday 22 April 2014 22:17
Target OS: OS X
Domoticz version: Beta
Location: France
Contact:

Re: Python Plugin: TUYA

Post by MacJL »

For those who are interested, I just found a workaround... ...by developing my own plugin!

As this Tuya device was supported by an Homebridge plugin, I developed a Domoticz plugin to get infos and control Homebridge in Insecure mode.
https://github.com/macjl/Domoticz-HomekitInsecureClient

Now I’m able to switch on and off this Tuya Devive from Domoticz!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest