Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Python and python framework

Moderator: leecollings

frenchyyii
Posts: 53
Joined: Saturday 24 September 2016 18:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by frenchyyii »

Everything works except a meterial but I alsa had the problem before:

It s a bulb called
"A60 Wifi"

I receive the State,
I can switch off
I can change color and adjust intensity

But I can't switch on
It's the same for the four of them I have.

That for information, If it may help you to improve the plugin that is really fantastic.

Have a good day.

Eric
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: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

That is strange. are you on the latest version? If so can you run debug_discovery.py from the tools directory don't forget to edit and run with python3 and send the create dump.json to [email protected].
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
frenchyyii
Posts: 53
Joined: Saturday 24 September 2016 18:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by frenchyyii »

I have no idea why it only bugs with "swtch On" ....
dump is in your mailbox

Thanks
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: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

frenchyyii wrote: Saturday 04 March 2023 9:52 I have no idea why it only bugs with "swtch On" ....
dump is in your mailbox

Thanks
Yes thank you, just load it in. I see the command is send:
Command send to tuya :*********3fda128edc, {'commands': [{'code': 'switch_led', 'value': True}]}

Can you test something?
change line 163
SendCommandCloud(DeviceID, 'switch_led', True)
to
SendCommandCloud(DeviceID, 'switch_led', true)

restart pluigin and run again
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
frenchyyii
Posts: 53
Joined: Saturday 24 September 2016 18:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by frenchyyii »

No change, still working for "off" command but not "On"
frenchyyii
Posts: 53
Joined: Saturday 24 September 2016 18:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by frenchyyii »

Smartlife Tiny Tuya : handleThread: Credentials are incorrect!

I hate tuya :D
dgilbert2
Posts: 95
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: UK
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by dgilbert2 »

Question, has this script needed any security changes to work with the latest 2023.1 version of Domoticz? I'm nervous about updating to 2023.1 if all my existing scripts like this one will need updating? Thanks.
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: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

frenchyyii wrote: Saturday 04 March 2023 13:27 No change, still working for "off" command but not "On"
In the json the control is 'Boolean' True/False...

Code: Select all

      {
        "code": "switch_led",
        "name": "\u5f00\u5173",
        "type": "Boolean",
        "values": "{}"
      }
frenchyyii wrote: Saturday 04 March 2023 16:48 Smartlife Tiny Tuya : handleThread: Credentials are incorrect!

I hate tuya :D
Yep...
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
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

dgilbert2 wrote: Saturday 04 March 2023 16:58 Question, has this script needed any security changes to work with the latest 2023.1 version of Domoticz? I'm nervous about updating to 2023.1 if all my existing scripts like this one will need updating? Thanks.
No nothing to change, works out of the box with 2023.1
I'm nervous about updating to 2023.1
Make a full copy of the Domoticz directory, if you don't like it easy turn back.
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
frenchyyii
Posts: 53
Joined: Saturday 24 September 2016 18:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by frenchyyii »

Xenomes wrote: Saturday 04 March 2023 18:47
frenchyyii wrote: Saturday 04 March 2023 13:27 No change, still working for "off" command but not "On"
In the json the control is 'Boolean' True/False...

Code: Select all

      {
        "code": "switch_led",
        "name": "\u5f00\u5173",
        "type": "Boolean",
        "values": "{}"
      }
So It should work ? right ?
frenchyyii wrote: Saturday 04 March 2023 16:48 Smartlife Tiny Tuya : handleThread: Credentials are incorrect!

I hate tuya :D
Yep...
Does that appear often ?
Have a good evening and thanks
lamama1234
Posts: 14
Joined: Tuesday 17 October 2017 9:02
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by lamama1234 »

Hi & thanks for this plugin. I just installed today and getting the following log error:

Code: Select all

2023-03-07 14:59:59.074 Error: TinyTUYA: Call to function 'onHeartbeat' failed, exception details:
2023-03-07 14:59:59.075 Error: TinyTUYA: Traceback (most recent call last):
2023-03-07 14:59:59.075 Error: TinyTUYA: File "C:\Program Files (x86)\Domoticz\plugins\Domoticz-TinyTUYA-Plugin-Master\plugin.py", line 341, in onHeartbeat
2023-03-07 14:59:59.075 Error: TinyTUYA: _plugin.onHeartbeat()
2023-03-07 14:59:59.076 Error: TinyTUYA: File "C:\Program Files (x86)\Domoticz\plugins\Domoticz-TinyTUYA-Plugin-Master\plugin.py", line 302, in onHeartbeat
2023-03-07 14:59:59.076 Error: TinyTUYA: if time.time() - last_update < 60 and testData == False:
2023-03-07 14:59:59.076 Error: TinyTUYA: NameError: name 'last_update' is not defined
No Tuya devices added obviously.

Running SmartLife (only one device paired: smart water valve), Domoticz 2023.1 on Win7 w/ Python 3.8.

Thanks!
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: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

lamama1234 wrote: Tuesday 07 March 2023 14:06 Hi & thanks for this plugin. I just installed today and getting the following log error:
No Tuya devices added obviously.

Running SmartLife (only one device paired: smart water valve), Domoticz 2023.1 on Win7 w/ Python 3.8.

Thanks!
Solved in https://github.com/Xenomes/Domoticz-Tin ... /issues/30
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
lamama1234
Posts: 14
Joined: Tuesday 17 October 2017 9:02
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by lamama1234 »

Thanks Xenomes!

I returned to your TUYA-plugin to make things work till this was fixed. Btw, what are the main differences between your TinyTUYA plugin vs your legacy TUYA-plugin? The IOT API periodical subscription renewal may become a nuisance at some stage.

On a different note, in your TUYA-plugin i'm getting an occasional error I couldn't solve:

Code: Select all

2023-03-13 07:27:46.652 Error: Tuya: handleThread: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None)) line 215
Any tips on how to handle it?

Thanks again
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: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

lamama1234 wrote: Monday 13 March 2023 9:58 Btw, what are the main differences between your TinyTUYA plugin vs your legacy TUYA-plugin? The IOT API periodical subscription renewal may become a nuisance at some stage.
In the TinyTUYA there are many more devices that can be controlled. 'subscription renewal' is a big problem that not only penalizes this plugin, but others in the home automation scene as well. Hope there will be a solution, because the tuya develop team help on building the HA integration.
lamama1234 wrote: Monday 13 March 2023 9:58 On a different note, in your TUYA-plugin i'm getting an occasional error I couldn't solve:

Code: Select all

2023-03-13 07:27:46.652 Error: Tuya: handleThread: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None)) line 215
Looks like the site was not reachable, do you use a vpn or pihole?
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
lamama1234
Posts: 14
Joined: Tuesday 17 October 2017 9:02
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by lamama1234 »

Looks like the site was not reachable, do you use a vpn or pihole?
No, direct internet connection (even no CGNAT). Is there a way to tell if the culprit is my network or the remote server?

Also, can I extend the connection timeout duration (in plugin.py) to avoid this error?

Thanks
dgilbert2
Posts: 95
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: UK
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by dgilbert2 »

The TinyTUYA-Plugin has stopped updating my devices since this morning. I've got no errors in the log and my Tiny API subscription is still valid. Anyone else having problems today?

Nothing has been touched so this has come as a complete surprise.
dgilbert2
Posts: 95
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: UK
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by dgilbert2 »

The problem seems to be around when the plugin re-starts, I've discovered that doing a hardware update until it works, is my workaround. I don't know what's suddenly changed though unless its at the TUYA end?

I've also noticed that debug_discovery.py has random issues too, i.e. sometimes it just reports my list of devices as [ ], rather than my full device details.

All very odd?
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: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

I think there is a change at Tuya I will monitor it with my own system.
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
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by Xenomes »

dgilbert2 wrote: Saturday 01 April 2023 13:08 The problem seems to be around when the plugin re-starts, I've discovered that doing a hardware update until it works, is my workaround. I don't know what's suddenly changed though unless its at the TUYA end?

I've also noticed that debug_discovery.py has random issues too, i.e. sometimes it just reports my list of devices as [ ], rather than my full device details.

All very odd?
Did you do a update of Tinytuya to version 1.10.3 or higher?

Can you do a update of the modules?

Code: Select all

sudo pip3 install tinytuya requests charset-normalizer --upgrade
for docker

Code: Select all

sudo docker exec -it domoticz pip install tinytuya requests charset-normalizer --upgrade
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
dgilbert2
Posts: 95
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: UK
Contact:

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Post by dgilbert2 »

I've updated to latest tinytuya, same problem.

The second command though has broken my setup, I'm now getting these errors;

Code: Select all

2023-04-01 13:32:00.797 Error: TinyTUYA: Traceback (most recent call last):
2023-04-01 13:32:00.797 Error: TinyTUYA: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 60, in <module>
2023-04-01 13:32:00.797 Error: TinyTUYA: import tinytuya
2023-04-01 13:32:00.797 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/tinytuya/__init__.py", line 99, in <module>
2023-04-01 13:32:00.797 Error: TinyTUYA: from .Cloud import Cloud
2023-04-01 13:32:00.797 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/tinytuya/Cloud.py", line 36, in <module>
2023-04-01 13:32:00.797 Error: TinyTUYA: import requests
2023-04-01 13:32:00.797 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/requests/__init__.py", line 48, in <module>
2023-04-01 13:32:00.797 Error: TinyTUYA: from charset_normalizer import __version__ as charset_normalizer_version
2023-04-01 13:32:00.797 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/charset_normalizer/__init__.py", line 24, in <module>
2023-04-01 13:32:00.797 Error: TinyTUYA: from .api import from_bytes, from_fp, from_path
2023-04-01 13:32:00.797 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/charset_normalizer/api.py", line 5, in <module>
2023-04-01 13:32:00.797 Error: TinyTUYA: from .cd import (
2023-04-01 13:32:00.797 Error: TinyTUYA: File "/usr/local/lib/python3.9/dist-packages/charset_normalizer/cd.py", line 9, in <module>
2023-04-01 13:32:00.797 Error: TinyTUYA: from .md import is_suspiciously_successive_range
2023-04-01 13:32:00.797 Error: TinyTUYA: AttributeError: PyCapsule_Import "charset_normalizer.md__mypyc.init_charset_normalizer___md" is not valid
2023-04-01 13:32:40.916 Error: TinyTUYA: (tinytuya) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.9/dist-packages'.
The third one gives error docker not found.

How to I get my system working again?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest