Page 1 of 19

[REQUEST] Plugin for Tuya

Posted: Friday 09 March 2018 1:34
by viruscz
Hi there,
i am not a programer :( , but i am asking if somebody is able to make or port the plugin for Tuya.
What i finded till now:

https://www.tuya.com/

the app on mible is: SmartLife and is used for Smart plugs, smart bulbs, smart swiches from alliexpress

Somebody made a api for this.
https://github.com/codetheweb/tuyapi
https://github.com/codetheweb/tuyapi/bl ... s/SETUP.md

and also was ported to other platforms:
https://github.com/codetheweb/homebridge-tuya-outlet
https://github.com/clach04/python-tuya

thnak you in advans :geek:

Re: [REQUEST] Plugin for Tuya

Posted: Tuesday 19 June 2018 19:05
by dxfantome1
I would be very interested too.
This is what I found:
https://www.letscontrolit.com/forum/vie ... c&start=30
https://www.letscontrolit.com/forum/vie ... php?t=5431
https://github.com/domoticz/domoticz/issues/2216
In brief everybody if intérresse but nobody finds solution for dimmer lowcost

Re: [REQUEST] Plugin for Tuya

Posted: Friday 31 August 2018 11:57
by fratton
you can use ifttt to control from domoticz with webhook request same :
domo.png
domo.png (84.97 KiB) Viewed 36991 times
webhook.jpg
webhook.jpg (57.31 KiB) Viewed 36991 times

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 06 September 2018 22:14
by kluczus
Nice but I prefer to be a cloud independent. Any chance to use it in different way ?

Re: [REQUEST] Plugin for Tuya

Posted: Friday 14 September 2018 10:47
by tixi7
Hi all,

You can find a python plugin that I developed for Tuya Smart Plug here:
https://github.com/tixi/Domoticz-Tuya-SmartPlug-Plugin

I am preparing another one for RGB Smart Bulb.
In the meanwhile this plugin should work to switch on/off a bulb.

Re: [REQUEST] Plugin for Tuya

Posted: Monday 24 September 2018 18:54
by tixi7
I put a new version of the plugin for the plug which should work better.
Let me know for issues.

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 27 September 2018 18:46
by kluczus
Nice job. I have a lot of errors from this plugin

Code: Select all

2018-09-27 18:21:11.638 Error: CConnection_disconnect, disconnection request from 'test1' ignored. Transport is not connecting or connected.
2018-09-27 18:21:11.640 Error: (test1) Disconnected from: 192.168.0.30:6668

Re: [REQUEST] Plugin for Tuya

Posted: Wednesday 03 October 2018 15:33
by tixi7
Thanks for the feedback.
I update the plugin and these error messages should not occur anymore.

Re: [REQUEST] Plugin for Tuya

Posted: Sunday 07 October 2018 9:32
by tixi7
Hi all,

I have just finished a first version for the bulb. You can find the plugin here:
https://github.com/tixi/Domoticz-Tuya-SmartBulb-Plugin

Let me know for issues.

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 11 October 2018 9:38
by dinamitemic
Hi, i've now installed your plugin and I'll test it to let you know if I notice some issues.
Thank you a lot for your work!!

Re: [REQUEST] Plugin for Tuya

Posted: Friday 12 October 2018 16:27
by dinamitemic
Hi, i've done all the stuff to get the devid and the key, then i've installed all the required package and your plugin, it appear on domoticz hardware page but when i try to add my switch all the domoticz software stop working, i can't no more access the page until i disinstall the plugin.

Running Domoticz v4.10007 on a Raspberry Pi 1

Re: [REQUEST] Plugin for Tuya

Posted: Saturday 13 October 2018 16:21
by tixi7
Can you provide more details:
- the plugin: plug or bulb?
- the version of the plugin, since the post I patch the bulb plugin to avoid a similar behavior
- some logs information
- device informations,

Can you try with the latest stable version of domoticz? I observe that some beta version causes problems: a bug report for domoticz is on my todo list.

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 18 October 2018 16:14
by frenchyyii
Hi, I tried the plug plugin ut I thinks I have a python directory problem. Could you help me ? Regards
DZ v: 4.10.078 beta
RPI3
log:

2018-10-18 16:01:27.313 Error: (tixi_tuya_smartplug_plugin) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-10-18 16:01:27.313 Error: (Prise multiple Tuya) Module Import failed, exception: 'ImportError'
2018-10-18 16:01:27.313 Error: (Prise multiple Tuya) Module Import failed: ' Name: pyaes'
2018-10-18 16:01:27.313 Error: (Prise multiple Tuya) Error Line details not available.

Regards

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 18 October 2018 20:37
by tixi7
Can you provide me the output of the command:

Code: Select all

pip3 show pycrypto

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 18 October 2018 20:55
by frenchyyii
A big thanks for your help, here is the response:

pi@raspberrypi:/usr/lib/python3.4/dist-packages $ pip3 show pycrypto

Name: pycrypto
Version: 2.6.1
Summary: Cryptographic modules for Python.
Home-page: http://www.pycrypto.org/
Author: Dwayne C. Litzenberger
Author-email: [email protected]
License: UNKNOWN
Location: /home/pi/.local/lib/python3.5/site-packages
Requires:

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 18 October 2018 22:55
by tixi7
did you add a symbolic link to pycrypto? (know issue section of the plugin description)

According to the output of pip3 show pycrypto the command lines should be:

Code: Select all

cd ~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin
ln -s /home/pi/.local/lib/python3.5/site-packages/Crypto Crypto
and then you need to restart domoticz

Re: [REQUEST] Plugin for Tuya

Posted: Friday 19 October 2018 0:40
by frenchyyii
Thanks it's much better !!
I did read many things and docs concerning the python problem but didn't look at that part... :oops:
As I have a multiplug (3+usb) for the moment I can only drive one plug but i'll take a look to see if I can add the 2 other ones and the USB one.

Re: [REQUEST] Plugin for Tuya

Posted: Friday 19 October 2018 7:21
by tixi7
The plugin is not designed to manage multiplug.

It will not be straightforward to adapt it.
I can try to do it but it will take some time for sure and the main issue will be for testing because I do not have such plug and do not plan to have it in the near future.

If you can test it, i will try.

To help, can you provide me the dps information of your plug. For that, you have to set debug to true and then when you observe an "onMessage called" in the log you should have in the middle of some message "dps". What i would like to see is the information just after, for single plug it is like this:
{"1":true,"11":0}}.

Re: [REQUEST] Plugin for Tuya

Posted: Friday 19 October 2018 16:07
by frenchyyii
Hi
I think I need to activate a deeper lo because I only have those informations:

Code: Select all

2018-10-19 07:52:50.901 (Prise multiple Tuya) Pushing 'onHeartbeatCallback' on to queue
2018-10-19 07:52:50.943 (Prise multiple Tuya) Processing 'onHeartbeatCallback' message
2018-10-19 07:52:50.944 (Prise multiple Tuya) Calling message handler 'onHeartbeat'.
2018-10-19 07:52:50.944 (Prise multiple Tuya) Pushing 'WriteDirective' on to queue
2018-10-19 07:52:50.944 (Prise multiple Tuya) Processing 'WriteDirective' message
2018-10-19 07:52:50.944 (Prise multiple Tuya) Sending 86 bytes of data
2018-10-19 07:52:50.944 (Prise multiple Tuya) 00 00 55 aa 00 00 00 00 00 00 00 0a 00 00 00 46 7b 22 67 77 ..U�...........F{"gw
2018-10-19 07:52:50.944 (Prise multiple Tuya) 49 64 22 3a 22 38 35 35 30 32 33 35 34 38 30 37 64 33 61 35 Id":"85502354807d3a5
2018-10-19 07:52:50.944 (Prise multiple Tuya) 30 62 38 65 65 22 2c 22 64 65 76 49 64 22 3a 22 38 35 35 30 0b8ee","devId":"8550
2018-10-19 07:52:50.944 (Prise multiple Tuya) 32 33 35 34 38 30 37 64 33 61 35 30 62 38 65 65 22 7d 00 00 2354807d3a50b8ee"}..
2018-10-19 07:52:50.944 (Prise multiple Tuya) 00 00 00 00 aa 55 .. .. .. .. .. .. .. .. .. .. .. .. .. .. ....�U
2018-10-19 07:52:51.124 (Prise multiple Tuya) Pushing 'ReadEvent' on to queue
2018-10-19 07:52:51.145 (Prise multiple Tuya) Processing 'ReadEvent' message
2018-10-19 07:52:51.145 (Prise multiple Tuya) Received 107 bytes of data
2018-10-19 07:52:51.145 (Prise multiple Tuya) 00 00 55 aa 00 00 00 00 00 00 00 0a 00 00 00 5b 00 00 00 00 ..U�...........[....
2018-10-19 07:52:51.145 (Prise multiple Tuya) 7b 22 64 65 76 49 64 22 3a 22 38 35 35 30 32 33 35 34 38 30 {"devId":"8550235480
2018-10-19 07:52:51.145 (Prise multiple Tuya) 37 64 33 61 35 30 62 38 65 65 22 2c 22 64 70 73 22 3a 7b 22 7d3a50b8ee","dps":{"
2018-10-19 07:52:51.145 (Prise multiple Tuya) 31 22 3a 66 61 6c 73 65 2c 22 32 22 3a 66 61 6c 73 65 2c 22 1":false,"2":false,"
2018-10-19 07:52:51.145 (Prise multiple Tuya) 33 22 3a 66 61 6c 73 65 2c 22 37 22 3a 74 72 75 65 7d 7d 87 3":false,"7":true}}�
2018-10-19 07:52:51.145 (Prise multiple Tuya) a2 56 60 00 00 aa 55 .. .. .. .. .. .. .. .. .. .. .. .. .. �V`..�U
2018-10-19 07:52:51.145 (Prise multiple Tuya) Pushing 'onMessageCallback' on to queue
2018-10-19 07:52:51.145 (Prise multiple Tuya) Processing 'onMessageCallback' message
2018-10-19 07:52:51.145 (Prise multiple Tuya) Calling message handler 'onMessage'.
2018-10-19 07:52:51.146 (Prise multiple Tuya) onMessage called: 192.168.2.215:6668 b'\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00[\x00\x00\x00\x00{"devId":"85502354807d3a50b8ee","dps":{"1":false,"2":false,"3":false,"7":true}}\x87\xa2V`\x00\x00\xaaU'

Re: [REQUEST] Plugin for Tuya

Posted: Friday 19 October 2018 19:38
by tixi7
Perfect, you have it in the last line:
"dps":{"1":false,"2":false,"3":false,"7":true}}

I guess that the 3 plugs were off and the usb on when you did it. correct?

Do you have a timer for your plug with the tuya app? I suspect no but can you confirm?

Thanks