Page 14 of 26

Re: Python Plugin: TUYA

Posted: Sunday 02 May 2021 19:41
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 ?

Re: Python Plugin: TUYA

Posted: Sunday 02 May 2021 21:14
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.

Re: Python Plugin: TUYA

Posted: Monday 03 May 2021 21:35
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?

Re: Python Plugin: TUYA

Posted: Monday 03 May 2021 22:06
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?

Re: Python Plugin: TUYA

Posted: Monday 03 May 2021 22:49
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 ?

Re: Python Plugin: TUYA

Posted: Monday 03 May 2021 22:57
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.

Re: Python Plugin: TUYA

Posted: Tuesday 04 May 2021 18:12
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?

Re: Python Plugin: TUYA

Posted: Tuesday 04 May 2021 18:51
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 😆

Re: Python Plugin: TUYA

Posted: Saturday 08 May 2021 15:45
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.

Re: Python Plugin: TUYA

Posted: Tuesday 11 May 2021 22:48
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?

Re: Python Plugin: TUYA

Posted: Wednesday 12 May 2021 22:11
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/

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 20:30
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

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 20:34
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.

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 20:36
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 !!!

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 20:39
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

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 20:48
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.

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 20:54
by technoholic
Yes it’s 3.9.x, can’t remember the exact version. Which version should I use?

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 21:04
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.

Re: Python Plugin: TUYA

Posted: Tuesday 01 June 2021 22:30
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?

Re: Python Plugin: TUYA

Posted: Wednesday 02 June 2021 21:39
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.