[REQUEST] Plugin for Tuya
Moderator: leecollings
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Good to know. To turn on/off the complete plug, you can use a group in domoticz.
I never try but no one report a bug on that. Let me know if it's ok.
I never try but no one report a bug on that. Let me know if it's ok.
-
- Posts: 234
- Joined: Sunday 27 August 2017 18:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Spain
- Contact:
Re: [REQUEST] Plugin for Tuya
hi,
yes the group is one method but in the tuya app there is a button for the complet plug. this not exist in the api?
thanks a lot!
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
The problem is not the api for that.
I can add another switch for all the plugs but the problem i have is how to define its state.
If some sockets are on and some others are off, that switch will be in one of the two modes and the on (or the off) button will not be available.
I can add 2 switches one for off and one for on but it will become not usable with many different devices.
Except if i miss something for that in domoticz, groups seems to be a better option.
I can add another switch for all the plugs but the problem i have is how to define its state.
If some sockets are on and some others are off, that switch will be in one of the two modes and the on (or the off) button will not be available.
I can add 2 switches one for off and one for on but it will become not usable with many different devices.
Except if i miss something for that in domoticz, groups seems to be a better option.
-
- Posts: 234
- Joined: Sunday 27 August 2017 18:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Spain
- Contact:
Re: [REQUEST] Plugin for Tuya
ok. i understand.tixi7 wrote: ↑Sunday 18 November 2018 20:51 The problem is not the api for that.
I can add another switch for all the plugs but the problem i have is how to define its state.
If some sockets are on and some others are off, that switch will be in one of the two modes and the on (or the off) button will not be available.
I can add 2 switches one for off and one for on but it will become not usable with many different devices.
Except if i miss something for that in domoticz, groups seems to be a better option.
The app of tuya have this button and works like this:
- If some plug are on and i push the "master button" all the plugs power offs
- If the master button is off, and i push, then all the plugs power on
I dont know if this is the best way but is the way that works the tuya app.
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
tixi7 wrote: ↑Sunday 18 November 2018 0:41 Sorry for the delay, I didn't get mail notifications from the forum...
For the smart plug i put a script on github to get the dps values (get_dps.py present in the multiplug branch).
It is a simple script that get the state and returns dps values with a boolean field.
Some comments for the bug that seems to be present in multi socket and bulb:
- You have to close the tuya app before using the plugin otherwise the plugin will not be able to connect to the device. Be sure that the app is not running in background. This is mandatory since the device support only one connection at a time.
It may be the cause of the plugin crash and unfortunately domoticz as well. If it is your case and you do not get an error when the tuya app is close, please can you send me the domoticz version you use (for a bug report to domoticz)
- If you see the update in domoticz it means that the devID and dps is valid.
- If you are not able to change the state from domoticz, the first thing to do is to double check the Local Key. The local key is needed only to change the state.
Now if the problem persist:
- you can try the turnON.py and turnOFF.py. (present in the multiplug branch) you have to provide : <IP> <DevID> <Local key> <DPS value>
for smartbulb the dps value should be 1 but please check before with the get_dps.py script.
These scripts will do exactly the job but outside domoticz. You have to deactivate the device in domoticz first.
If with the script, the problem persist, it means that it is not plugin related but the library. I guess your problem is related to the issue discussed here: https://github.com/codetheweb/tuyapi/is ... -437593018
In this case, I will not be able to fix it until they found a way to deal with such devices.
Hi,
i've tried to use the turnON.py script but i've this error:
- Spoiler: show
Can you help me to solve this problem?
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
This is what happens in my domoticz log when i add tuya hardware:
Async Read Exception: 104, Connection reset by peer
- Spoiler: show
Async Read Exception: 104, Connection reset by peer
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
For the import error, check the readme. You have to install pycrypto (section prerequisites) and then add a symbolic link to it in the plugin directory (section known issue).
For the 104, Connection reset by peer it may come from two different factors:
- tuya app open
- device not reachable (if you turn off the physical switch of your bulb)
For the 104, Connection reset by peer it may come from two different factors:
- tuya app open
- device not reachable (if you turn off the physical switch of your bulb)
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi Tixi,tixi7 wrote: ↑Tuesday 20 November 2018 20:33 For the import error, check the readme. You have to install pycrypto (section prerequisites) and then add a symbolic link to it in the plugin directory (section known issue).
For the 104, Connection reset by peer it may come from two different factors:
- tuya app open
- device not reachable (if you turn off the physical switch of your bulb)
Regarding the import error with TurnOn.py script, i've alredy installed the pycrypto and added the symbolic link in the plugin directory (in fact the smartbulb plugin start without this error). I've copied the TurnOn.py in the same directory but when i start it,i've the error. it's very strange.
Regarding the 104 connection error, i've removed the app from my phone but the error is still present.
Domoticz version is 4.9701
Thank you.
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: [REQUEST] Plugin for Tuya
Have you tried to install pyaes already ?Hi,
i've tried to use the turnON.py script but i've this error:
- Spoiler: show
Can you help me to solve this problem?
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi,i managed to make it work.
Launching the get_dps.py script i've this result:
Plug State Information:
{u'devId': u'xxxxxxxxxxxxx', u'dps': {u'10': u'ffff0505ff000000ff00ffff00ff00ff0000ff000000', u'1': True, u'3': 255, u'2': u'colour', u'5': u'ff00fb012dffff', u'7': u'ffff500100ff00', u'6': u'00ff0000000000', u'9': u'ffff5001ff0000', u'8': u'ffff8003ff000000ff000000ff000000000000000000'}}
Plug DPS List:
1
Launching the script now i've the error:
Traceback (most recent call last):
File "turnON.py", line 51, in <module>
except (ConnectionResetError, socket.timeout, OSError) as e:
NameError: name 'ConnectionResetError' is not defined
Launching the get_dps.py script i've this result:
Plug State Information:
{u'devId': u'xxxxxxxxxxxxx', u'dps': {u'10': u'ffff0505ff000000ff00ffff00ff00ff0000ff000000', u'1': True, u'3': 255, u'2': u'colour', u'5': u'ff00fb012dffff', u'7': u'ffff500100ff00', u'6': u'00ff0000000000', u'9': u'ffff5001ff0000', u'8': u'ffff8003ff000000ff000000ff000000000000000000'}}
Plug DPS List:
1
Launching the script now i've the error:
Traceback (most recent call last):
File "turnON.py", line 51, in <module>
except (ConnectionResetError, socket.timeout, OSError) as e:
NameError: name 'ConnectionResetError' is not defined
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
What is your python version when you launch the script turnON.py?
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
if i digit:
python -V
it gives me 2.7.12
i've installed 3.5 but using the command
python -V it gives me the 2.7.12
The two versions are installed in directory /usr/local/lib
Then i've tried to launche the script with command python3 and the result is:
A problem occur please retry...
I've tried using command
python3 -V
and it gives me 3.5.2
I've Ubuntu 16.04
python -V
it gives me 2.7.12
i've installed 3.5 but using the command
python -V it gives me the 2.7.12
The two versions are installed in directory /usr/local/lib
Then i've tried to launche the script with command python3 and the result is:
A problem occur please retry...
I've tried using command
python3 -V
and it gives me 3.5.2
I've Ubuntu 16.04
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
The script is for python3 because of ConnectionResetError.
When you use the script do have the plugin enable? or the tuya app?
When you use the script do have the plugin enable? or the tuya app?
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi tixi,
i've no app installed on my phone and there is no plugin enabled on domoticz
i've no app installed on my phone and there is no plugin enabled on domoticz
-
- Posts: 34
- Joined: Tuesday 23 February 2016 9:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: NL
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi,
I have purchased this power powerplug.
https://www.aliexpress.com/item/Smart-P ... 4c4dt2kXMJ
Can the script also read out the Wattage usage ?
John
I have purchased this power powerplug.
https://www.aliexpress.com/item/Smart-P ... 4c4dt2kXMJ
Can the script also read out the Wattage usage ?
John
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
vrega, I do not see why you got that ConnectionResetError. Are you sure about your Local key, how did you get it?
jslegers, for sure the plugin is not define for it and i don't know if the library can get it or not. Can you send me the result of the script get_dps.py.
jslegers, for sure the plugin is not define for it and i don't know if the library can get it or not. Can you send me the result of the script get_dps.py.
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi,
I've captured traffic on My phone during the lamp registration with the app and after i've analyzed and
extracted the keys.
Is there a simplest way to re-check it?
I've captured traffic on My phone during the lamp registration with the app and after i've analyzed and
extracted the keys.
Is there a simplest way to re-check it?
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
https://github.com/codetheweb/tuyapi/bl ... s/SETUP.md
I use a previous version (check history if needed).
I use a previous version (check history if needed).
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: [REQUEST] Plugin for Tuya
-
- Posts: 15
- Joined: Wednesday 13 December 2017 10:12
- Target OS: Linux
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi Tixi,tixi7 wrote: ↑Friday 23 November 2018 21:45 https://github.com/codetheweb/tuyapi/bl ... s/SETUP.md
I use a previous version (check history if needed).
you were right.
I've used your method to extract key and mine was wrong. Now it works. Thank you.
Who is online
Users browsing this forum: No registered users and 0 guests