[REQUEST] Plugin for Tuya

Python and python framework
viruscz
Posts: 3
Joined: Friday 09 March 2018 2:24
Target OS: Raspberry Pi
Domoticz version: beta
Location: Czech Republic
Contact:

[REQUEST] Plugin for Tuya

Post by viruscz » Friday 09 March 2018 2:34

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:

dxfantome1
Posts: 3
Joined: Monday 18 June 2018 12:07
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by dxfantome1 » Tuesday 19 June 2018 19:05

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

User avatar
fratton
Posts: 12
Joined: Tuesday 08 December 2015 18:23
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: [REQUEST] Plugin for Tuya

Post by fratton » Friday 31 August 2018 11:57

you can use ifttt to control from domoticz with webhook request same :
domo.png
domo.png (84.97 KiB) Viewed 2094 times
webhook.jpg
webhook.jpg (57.31 KiB) Viewed 2094 times

kluczus
Posts: 25
Joined: Tuesday 12 September 2017 14:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by kluczus » Thursday 06 September 2018 22:14

Nice but I prefer to be a cloud independent. Any chance to use it in different way ?
........................................................................................
RPi2 + sonoff + 433MHz + Xiaomi Gateway + EQ-3 MAX!

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Friday 14 September 2018 10:47

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.

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Monday 24 September 2018 18:54

I put a new version of the plugin for the plug which should work better.
Let me know for issues.

kluczus
Posts: 25
Joined: Tuesday 12 September 2017 14:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by kluczus » Thursday 27 September 2018 18:46

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
........................................................................................
RPi2 + sonoff + 433MHz + Xiaomi Gateway + EQ-3 MAX!

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Wednesday 03 October 2018 15:33

Thanks for the feedback.
I update the plugin and these error messages should not occur anymore.

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Sunday 07 October 2018 9:32

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.

User avatar
dinamitemic
Posts: 5
Joined: Thursday 11 October 2018 9:11
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by dinamitemic » Thursday 11 October 2018 9:38

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!!

User avatar
dinamitemic
Posts: 5
Joined: Thursday 11 October 2018 9:11
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by dinamitemic » Friday 12 October 2018 16:27

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

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Saturday 13 October 2018 16:21

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.

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

Re: [REQUEST] Plugin for Tuya

Post by frenchyyii » Thursday 18 October 2018 16:14

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

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Thursday 18 October 2018 20:37

Can you provide me the output of the command:

Code: Select all

pip3 show pycrypto

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

Re: [REQUEST] Plugin for Tuya

Post by frenchyyii » Thursday 18 October 2018 20:55

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: dlitz@dlitz.net
License: UNKNOWN
Location: /home/pi/.local/lib/python3.5/site-packages
Requires:

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Thursday 18 October 2018 22:55

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

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

Re: [REQUEST] Plugin for Tuya

Post by frenchyyii » Friday 19 October 2018 0:40

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.

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Friday 19 October 2018 7:21

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}}.

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

Re: [REQUEST] Plugin for Tuya

Post by frenchyyii » Friday 19 October 2018 16:07

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'

tixi7
Posts: 32
Joined: Monday 10 September 2018 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tixi7 » Friday 19 October 2018 19:38

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests