Python Plugin: TUYA

Python and python framework

Moderator: leecollings

Bobby08
Posts: 7
Joined: Saturday 01 May 2021 19:57
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Bobby08 »

Ah yes i forgot that, its ok now thanks again.

And for my scenes, i created scenes in domotics that works but the ones created in smartlife do nothing, is it normal ?
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 »

Bobby08 wrote: Sunday 02 May 2021 19:41 And for my scenes, i created scenes in domotics that works but the ones created in smartlife do nothing, is it normal ?
I never used the scene function in Tuya-based apps. I just set one up to test that it works but found out that it is an on/off switch device in Domoticz. So I changed the button function in the plug-in to a push-on button so to start a scene.
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
ziaziung
Posts: 9
Joined: Friday 13 February 2015 10:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by ziaziung »

Hi. I have installed Domoticz-TUYA-Plugin in my Domoticz.

Here what I get in log :

Code: Select all

 2021-05-03 21:34:26.549 Error: (tuya) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TUYA-Plugin/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload:/usr/local/lib/python3.4/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.4/dist-packages:/usr/lib/dist-python'.
2021-05-03 21:34:26.549 Error: (TuyaPlug) Module Import failed, exception: 'SyntaxError'
2021-05-03 21:34:26.549 Error: (TuyaPlug) Import detail: File: /usr/local/lib/python3.4/dist-packages/tuyaha/tuyaapi.py, Line: 69, offset: 87
2021-05-03 21:34:26.550 Error: (TuyaPlug) Error Line ' f"Discovery interval below {MIN_DISCOVERY_INTERVAL} seconds is invalid"
2021-05-03 21:34:26.550 ' 

An idea?
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 »

ziaziung wrote: Monday 03 May 2021 21:35 Hi. I have installed Domoticz-TUYA-Plugin in my Domoticz.

Here what I get in log :

Code: Select all

 2021-05-03 21:34:26.549 Error: (tuya) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TUYA-Plugin/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload:/usr/local/lib/python3.4/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.4/dist-packages:/usr/lib/dist-python'.
2021-05-03 21:34:26.549 Error: (TuyaPlug) Module Import failed, exception: 'SyntaxError'
2021-05-03 21:34:26.549 Error: (TuyaPlug) Import detail: File: /usr/local/lib/python3.4/dist-packages/tuyaha/tuyaapi.py, Line: 69, offset: 87
2021-05-03 21:34:26.550 Error: (TuyaPlug) Error Line ' f"Discovery interval below {MIN_DISCOVERY_INTERVAL} seconds is invalid"
2021-05-03 21:34:26.550 ' 

An idea?
Idd you install the required pip3 modules?
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
ziaziung
Posts: 9
Joined: Friday 13 February 2015 10:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by ziaziung »

Yes I think : requets,
Here what I get :

Code: Select all

sudo pip3 install tuyaha requests
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
    ['__name__'])
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
    from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
How can I do to re-install the whole ?
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 »

ziaziung wrote: Monday 03 May 2021 22:49 Yes I think : requets,
Here what I get :

How can I do to re-install the whole ?
That's look not good... looks somting is broken.
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
jpbriaire
Posts: 10
Joined: Friday 28 July 2017 21:26
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by jpbriaire »

ziaziung wrote: Monday 03 May 2021 21:35 Hi. I have installed Domoticz-TUYA-Plugin in my Domoticz.

Here what I get in log :

Code: Select all

 2021-05-03 21:34:26.549 Error: (tuya) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TUYA-Plugin/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload:/usr/local/lib/python3.4/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.4/dist-packages:/usr/lib/dist-python'.
2021-05-03 21:34:26.549 Error: (TuyaPlug) Module Import failed, exception: 'SyntaxError'
2021-05-03 21:34:26.549 Error: (TuyaPlug) Import detail: File: /usr/local/lib/python3.4/dist-packages/tuyaha/tuyaapi.py, Line: 69, offset: 87
2021-05-03 21:34:26.550 Error: (TuyaPlug) Error Line ' f"Discovery interval below {MIN_DISCOVERY_INTERVAL} seconds is invalid"
2021-05-03 21:34:26.550 ' 

An idea?
I have the same problem. I think it has something to do with a Python update on Synology. Can that be the problem? And if so, how do we fix it?
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 »

jpbriaire wrote: Tuesday 04 May 2021 18:12 I have the same problem. I think it has something to do with a Python update on Synology. Can that be the problem? And if so, how do we fix it?
For installing on a NAS please see this link chapter 'Install Domoticz tuya cloud plugin'
ziaziung wrote: Monday 03 May 2021 22:49 How can I do to re-install the whole ?
Are you running it on a Raspberry PI or NAS? Your 'Target OS' say RPI but your Python 3.4 is a older version like on a NAS 😆
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
jpbriaire
Posts: 10
Joined: Friday 28 July 2017 21:26
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by jpbriaire »

Xenomes wrote: Tuesday 04 May 2021 18:51
For installing on a NAS please see this link chapter 'Install Domoticz tuya cloud plugin'
Installing is not the problem. I had it working just fine. But then it stopped working and I got the same errors in Domoticz. And I think this has something to do with a Python update that has recently been executed on my NAS.
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 »

Just for my understanding. I am controlling a number of lamps via the Tuya app, and from Domoticz using the Tuya plugin.
I think this means that the app interfaces with the Tuya cloud server to control my lamps. Am I right?
If so, is there any way to control the lamps locally, so without interfacing with the cloud server?
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: Tuesday 11 May 2021 22:48 Just for my understanding. I am controlling a number of lamps via the Tuya app, and from Domoticz using the Tuya plugin.
I think this means that the app interfaces with the Tuya cloud server to control my lamps. Am I right?
Yes it is 😆
manjh wrote: Tuesday 11 May 2021 22:48 If so, is there any way to control the lamps locally, so without interfacing with the cloud server?
Here are some local plugins, but you need the local Key of all your devices.
https://github.com/tixi/Domoticz-Tuya-SmartPlug-Plugin
https://github.com/tixi/Domoticz-Tuya-SmartBulb-Plugin
https://github.com/carloscastro72/Domot ... ind-Plugin

Scripts also local Key needed:
https://github.com/BreizhCat/domoticz-tuya
https://github.com/Canard64/Domoticz-Tuya (tutorial for getting local Key)

Alternative firmware doesn't work with all devices. (⚠ at your own risk ⚠)
https://tasmota.github.io/docs/Tuya-Convert/
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
technoholic
Posts: 18
Joined: Monday 23 November 2015 12:37
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by technoholic »

Can someone help?! I'm on the verge of giving up!

I've finally managed to get this plug in to pretty much work on a Windows based install. It needs to be Windows for various other reasons.

debug_discovery returns the correct device which is a Smart Aroma Diffuser.

To get the plugin to work in Domoticz I had to add the tuyaha folder from the developers page, version 0.0.10. The plugin then starts and eventually it will show in the log that it sees the device in the account, online, but it never adds it to the device list, so I can't control it. I have no idea why but I would really like to integrate this into my scenes with the aim of automating the house fragrancing!

Can anyone help? I'm running v 1.0.9 of the plugin
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 »

technoholic wrote: Tuesday 01 June 2021 20:30 Can someone help?! I'm on the verge of giving up!

I've finally managed to get this plug in to pretty much work on a Windows based install. It needs to be Windows for various other reasons.

debug_discovery returns the correct device which is a Smart Aroma Diffuser.

To get the plugin to work in Domoticz I had to add the tuyaha folder from the developers page, version 0.0.10. The plugin then starts and eventually it will show in the log that it sees the device in the account, online, but it never adds it to the device list, so I can't control it. I have no idea why but I would really like to integrate this into my scenes with the aim of automating the house fragrancing!

Can anyone help? I'm running v 1.0.9 of the plugin
Can you post the result of debug_discovery? Then we can see if the device is supported by the API. The plugin has no support for any 'Smart Aroma Diffuser' yet.
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
technoholic
Posts: 18
Joined: Monday 23 November 2015 12:37
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by technoholic »

Getting credentials
Got credentials
{ 'access_token': 'EUheu1622568543255hb1Dmy87yoejltq',
'expires_in': 864000,
'refresh_token': 'EUheu1622568543255hb1DmcrTHKdQKT9',
'token_type': 'bearer'}
Getting devices
Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': { 'devices': [ { 'data': {'online': True, 'state': False},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/ay ... 7ad06b.jpg',
'id': 'bf2c8d53f615c4c2d0twpi',
'name': 'Smart Aroma Diffuser'}],
'scenes': []}}
!!! NOW REMOVE THIS FILE, SO YOUR CREDENTIALS (username, password) WON'T LEAK !!!
technoholic
Posts: 18
Joined: Monday 23 November 2015 12:37
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by technoholic »

I am also now getting this in the log

2021-06-01 19:36:56.529 Error: CheckAuthToken(963b36e0dfe702b593d1767076fe0339_ZTIwYTBlMDgtNmQyOS00MjZlLTk5Y2QtZjQyNDA2MGI0MDcy) : auth token mismatch
2021-06-01 19:36:56.629 Error: CheckAuthToken(963b36e0dfe702b593d1767076fe0339_ZTIwYTBlMDgtNmQyOS00MjZlLTk5Y2QtZjQyNDA2MGI0MDcy) : session id not found
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 »

technoholic wrote: Tuesday 01 June 2021 20:36 'payload': { 'devices': [ { 'data': {'online': True, 'state': False},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/ay ... 7ad06b.jpg',
'id': 'bf2c8d53f615c4c2d0twpi',
'name': 'Smart Aroma Diffuser'}],
'scenes': []}}
Nice it see it as a switch and switches are supported 😆
technoholic wrote: Tuesday 01 June 2021 20:39 I am also now getting this in the log

2021-06-01 19:36:56.529 Error: CheckAuthToken(963b36e0dfe702b593d1767076fe0339_ZTIwYTBlMDgtNmQyOS00MjZlLTk5Y2QtZjQyNDA2MGI0MDcy) : auth token mismatch
2021-06-01 19:36:56.629 Error: CheckAuthToken(963b36e0dfe702b593d1767076fe0339_ZTIwYTBlMDgtNmQyOS00MjZlLTk5Y2QtZjQyNDA2MGI0MDcy) : session id not found
I don't understand where this error message is coming from. What is the version of python you are running? I know that version 3.9 of Python gives problems.
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
technoholic
Posts: 18
Joined: Monday 23 November 2015 12:37
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by technoholic »

Yes it’s 3.9.x, can’t remember the exact version. Which version should I use?
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 »

technoholic wrote: Tuesday 01 June 2021 20:54 Yes it’s 3.9.x, can’t remember the exact version. Which version should I use?
I use python Version: 3.7.3, i know it works under that vesion.
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
technoholic
Posts: 18
Joined: Monday 23 November 2015 12:37
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by technoholic »

Thank you, it worked!

So now I can control on/off through domoticz, it's good start. But through Tuya, you can control RGB settings and diffuser strength. Is there any way to enable those commands in Domoticz?
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 »

technoholic wrote: Tuesday 01 June 2021 22:30 Thank you, it worked!

So now I can control on/off through domoticz, it's good start. But through Tuya, you can control RGB settings and diffuser strength. Is there any way to enable those commands in Domoticz?
The api return only this

Code: Select all

Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': { 'devices': [ { 'data': {'online': True, 'state': False},
'dev_type': 'switch',
'ha_type': 'switch',
'icon': 'https://images.tuyaeu.com/smart/icon/ay ... 7ad06b.jpg',
'id': 'bf2c8d53f615c4c2d0twpi',
'name': 'Smart Aroma Diffuser'}]
The only control is State and the status online there is nothing to do about.
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
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest