Python Plugin: TUYA

Python and python framework

Moderator: leecollings

BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: TUYA

Post by BarryT »

Here is the video:
https://youtu.be/tNDmISinbsQ
As you can see the state of the knob goes from open to close(d) again (after 60 seconds), but there is NO command send after the knob goes to close..:)
Pardon me that i moved the camera on the end, but you could see the issue..
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
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 »

I understand what is going on, I have updated the https://github.com/Xenomes/Domoticz-TUY ... /plugin.py can you do it 60 sec wait and also post the log.
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
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: TUYA

Post by BarryT »

It is working now, status open will stay open and close will stay close...! Good job!
The only thing is that there is an error...:

Code: Select all

 Error: Tuya: (Tuya) handleThread: can only concatenate str (not "method") to str line 271

Code: Select all

2021-07-11 20:22:58.308  Status: Tuya: (Tuya) Entering work loop.
2021-07-11 20:22:58.308  Status: Tuya: (Tuya) Started.
2021-07-11 20:22:59.449  Status: Tuya: (Tuya) Initialized version 1.0.11, author 'Wagner Oliveira contributed Xenomes'
2021-07-11 20:22:59.451  Tuya: (Tuya) Waiting 60 seconds to connect TuyaApi login timeout

2021-07-11 20:24:13.026  Tuya: (Tuya) TUYA plugin started
2021-07-11 20:24:13.027  Tuya: (Tuya) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE 
2021-07-11 20:24:13.027  Tuya: (Tuya) 'HardwareID':'61'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'HomeFolder':'/home/pi/domoticz/plugins/Domoticz-TUYA-Plugin/'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'StartupFolder':'/home/pi/domoticz/'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'UserDataFolder':'/home/pi/domoticz/'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Database':'/home/pi/domoticz/domoticz.db'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Language':'nl'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Version':'1.0.11'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Author':'Wagner Oliveira contributed Xenomes'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Name':'Tuya'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Port':'0'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Key':'tuya'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Mode1':'31'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Mode2':'tuya'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'Mode6':'-1'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'DomoticzVersion':'2021.1 (build 13360)'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'DomoticzHash':'eee333c30'
2021-07-11 20:24:13.027  Tuya: (Tuya) 'DomoticzBuildTime':'2021-07-04 11:58:11'
2021-07-11 20:24:13.027  Tuya: (Tuya) Device count: 1
2021-07-11 20:24:13.027  Tuya: (Tuya) Device:           1 - ID: 2622, Name: 'Rolgordijn Keuken', nValue: 1, sValue: 'On'
2021-07-11 20:24:13.027  Tuya: (Tuya) Device ID:       '2622'
2021-07-11 20:24:13.028  Tuya: (Tuya) Device Name:     'Rolgordijn Keuken'
2021-07-11 20:24:13.028  Tuya: (Tuya) Device nValue:    1
2021-07-11 20:24:13.028  Tuya: (Tuya) Device sValue:   'On'
2021-07-11 20:24:13.028  Tuya: (Tuya) Device LastLevel: 0
2021-07-11 20:24:13.028  (Rolgordijn Keuken) Updating device from 1:'On' to have values 0:'Off'.
2021-07-11 20:24:13.044  Tuya: (Tuya) Update 0:'Off' (Rolgordijn Keuken) TimedOut=True
2021-07-11 20:24:13.045  Tuya: (Tuya) in handlethread
2021-07-11 20:24:13.048  (Tuya) Processing 'onStopCallback' message
2021-07-11 20:24:13.048  Tuya: (Tuya) Calling message handler 'onStop' on 'module' type object.
2021-07-11 20:24:13.048  Tuya: (Tuya) onStop called

Code: Select all

2021-07-11 20:27:16.173  Tuya: (Tuya) DEV name=Rolgordijn Keuken state=3 id=00660024a4e57***** online=True
Last edited by BarryT on Sunday 11 July 2021 20:55, edited 1 time in total.
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
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 »

Yes i see, it was in a log for the script, changed it. can u test again 😅
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
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: TUYA

Post by BarryT »

Xenomes wrote: Sunday 11 July 2021 20:55 Yes i see, it was in a log for the script, changed it. can u test again 😅
Sure, lol.. Hold'n a sec ;)
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: TUYA

Post by BarryT »

Still there... :(
2021-07-11 21:06:32.525 Error: Tuya: (Tuya) handleThread: can only concatenate str (not "int") to str line 271
Last edited by BarryT on Sunday 11 July 2021 21:13, edited 2 times in total.
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
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 »

The error was changed, added a string convert, can you test again 😎
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
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: TUYA

Post by BarryT »

Xenomes wrote: Sunday 11 July 2021 21:11 The error was changed, added a string convert, can you test again 😎
Eh, now the hole system is weird....

Code: Select all

2021-07-11 21:16:25.933 Error: Zigbee hardware (56) thread seems to have ended unexpectedly
2021-07-11 21:16:25.933 Error: Tuya hardware (61) thread seems to have ended unexpectedly
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
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 »

That is comment when a stop and restart is to quickly after eachother, use a stop and wait few sec then start.
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
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: TUYA

Post by BarryT »

Xenomes wrote: Sunday 11 July 2021 15:34 I understand what is going on, I have updated the https://github.com/Xenomes/Domoticz-TUY ... /plugin.py can you do it 60 sec wait and also post the log.
I downgraded to this version and disabled the debug that disables the error also. ;)
Everything okay for now.
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
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 »

BarryT wrote: Monday 12 July 2021 18:10
Xenomes wrote: Sunday 11 July 2021 15:34 I understand what is going on, I have updated the https://github.com/Xenomes/Domoticz-TUY ... /plugin.py can you do it 60 sec wait and also post the log.
I downgraded to this version and disabled the debug that disables the error also. ;)
Everything okay for now.
Merged the fix to the live version.
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
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: TUYA

Post by BarryT »

Xenomes wrote: Monday 12 July 2021 21:39
BarryT wrote: Monday 12 July 2021 18:10
Xenomes wrote: Sunday 11 July 2021 15:34 I understand what is going on, I have updated the https://github.com/Xenomes/Domoticz-TUY ... /plugin.py can you do it 60 sec wait and also post the log.
I downgraded to this version and disabled the debug that disables the error also. ;)
Everything okay for now.
Merged the fix to the live version.
Great job, it works :)
Thanks!
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
pvdk
Posts: 4
Joined: Tuesday 11 May 2021 15:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: Python Plugin: TUYA

Post by pvdk »

I installed the TUYA (Xenomes) plugin successfully and also the creation of the TUYA hardware in Domoticz was not a problem. Nevertheless, my device was not recognized.

I'm using Domoticz 2021.1 on Raspberry.
The Tuya device is a Wifi Temperature and Humidity Detector (TRD02-01A) which is accessed via the Smart Life app.

Are there any hints on how to progress?

Log:
2021-07-27 21:50:30.036 Status: Sensor: (Sensor) Entering work loop.
2021-07-27 21:50:30.036 Status: Sensor: (Sensor) Started.
2021-07-27 21:50:30.813 Status: Sensor: (Sensor) Initialized version 1.0.12, author 'Wagner Oliveira contributed Xenomes'
2021-07-27 21:51:30.865 Sensor: (Sensor) TUYA plugin started
2021-07-27 21:51:30.865 Sensor: (Sensor) Debug logging mask set to: PYTHON CONNECTION
2021-07-27 21:51:30.865 Sensor: (Sensor) 'HardwareID':'15'
2021-07-27 21:51:30.865 Sensor: (Sensor) 'HomeFolder':'/home/pi/domoticz/plugins/Domoticz-TUYA-Plugin/'
2021-07-27 21:51:30.865 Sensor: (Sensor) 'StartupFolder':'/home/pi/domoticz/'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'UserDataFolder':'/home/pi/domoticz/'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Database':'/home/pi/domoticz/domoticz.db'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Language':'en'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Version':'1.0.12'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Author':'Wagner Oliveira contributed Xenomes'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Name':'Sensor'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Port':'0'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Username’:’[email protected]'
2021-07-27 21:51:30.866 Sensor: (Sensor) 'Password’:’password’
2021-07-27 21:51:30.867 Sensor: (Sensor) 'Key':'tuya'
2021-07-27 21:51:30.867 Sensor: (Sensor) 'Mode1':'31'
2021-07-27 21:51:30.867 Sensor: (Sensor) 'Mode2':'smart_life'
2021-07-27 21:51:30.867 Sensor: (Sensor) 'Mode6':'18'
2021-07-27 21:51:30.867 Sensor: (Sensor) 'DomoticzVersion':'2021.1'
2021-07-27 21:51:30.867 Sensor: (Sensor) 'DomoticzHash':'8547c5b7e'
2021-07-27 21:51:30.867 Sensor: (Sensor) 'DomoticzBuildTime':'2021-04-17 17:29:11'
2021-07-27 21:51:30.867 Sensor: (Sensor) Device count: 0
2021-07-27 21:51:30.869 Sensor: (Sensor) in handlethread
2021-07-27 21:51:30.975 Sensor: (Sensor) onHeartbeat called time=1627415490.975322
2021-07-27 21:51:30.976 Sensor: (Sensor) in handlethread
2021-07-27 21:51:30.976 Sensor: (Sensor) Device count: 0
2021-07-27 21:51:40.051 Sensor: (Sensor) onHeartbeat called time=1627415500.0508928
2021-07-27 21:51:50.071 Sensor: (Sensor) onHeartbeat called time=1627415510.0713763
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 »

pvdk wrote: Tuesday 27 July 2021 21:58 I installed the TUYA (Xenomes) plugin successfully and also the creation of the TUYA hardware in Domoticz was not a problem. Nevertheless, my device was not recognized.

I'm using Domoticz 2021.1 on Raspberry.
The Tuya device is a Wifi Temperature and Humidity Detector (TRD02-01A) which is accessed via the Smart Life app.

Are there any hints on how to progress?
Can you configure and run the debug_discovery.py from the tools directory? please post the output here.
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
loeknl
Posts: 6
Joined: Saturday 04 July 2020 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by loeknl »

The Tuya plugin makes my system unstable and crashes Domoticz about two-three times a day. Any clue what can cause this?
Attachments
235171812_4269572049778587_494405493707012081_n.jpg
235171812_4269572049778587_494405493707012081_n.jpg (124.45 KiB) Viewed 1644 times
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by waltervl »

loeknl wrote: Monday 23 August 2021 22:56 The Tuya plugin makes my system unstable and crashes Domoticz about two-three times a day. Any clue what can cause this?
Stable or Beta release of Domoticz?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
loeknl
Posts: 6
Joined: Saturday 04 July 2020 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by loeknl »

waltervl wrote: Tuesday 24 August 2021 9:16 Stable or Beta release of Domoticz?
I use the stable 2021.1 From april 17h
And the up to date Tuya plugin (1.0.12)
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by waltervl »

It could be related to another python plugin. Disable them one by one and see if the crash will disappear.
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
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 »

loeknl wrote: Monday 23 August 2021 22:56 The Tuya plugin makes my system unstable and crashes Domoticz about two-three times a day. Any clue what can cause this?
That is strange I never had any issue when the plug-in is running.

This is a good tip.
waltervl wrote: Wednesday 25 August 2021 15:50 It could be related to another python plugin. Disable them one by one and see if the crash will disappear.
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
adelafug
Posts: 3
Joined: Wednesday 01 September 2021 19:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by adelafug »

Hello


I install plugin tuyaha and configure params. But when plugin call skill api i no receibe my devices. I used Tuya Smart with iphone.. And i have 1 device registred ( sensor door ).

I test api with Postman y receive the same response..

https://px1.tuyaeu.com/homeassistant/sk ... dVersion=1
BodY: {'header': {'name': 'Discovery', 'namespace': 'discovery', 'payloadVersion': 1}, 'payload': {'accessToken': 'EUheu16305128439555U07k8PoLsNpHsU'}}

Response.

{"payload":{"devices":[],"scenes":[]},"header":{"code":"SUCCESS","payloadVersion":1}}



Any idea?

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest