Page 5 of 26
Re: Python Plugin: TUYA
Posted: Monday 11 January 2021 12:38
by Xenomes
Great that it is fixed!
Re: Python Plugin: TUYA
Posted: Tuesday 12 January 2021 19:09
by Meeki
Xenomes wrote: ↑Wednesday 06 January 2021 21:37
Meeki wrote: ↑Wednesday 06 January 2021 20:43
Can you explain me how to do this? don't know how to run the script.
Kind regards/Groeten
Dennis
It is not difficult, edit the file and add you credentials and set it up as in Domoticz run it and post the output. edit it again and remove your credentials.
The setting to change:
Code: Select all
# CHANGE THIS - BEGGINING
USERNAME = ""
PASSWORD = ""
REGION = "eu" # cn, eu, us
COUNTRY_CODE = "1" # Your account country code, e.g., 1 for USA or 86 for China
BIZ_TYPE = "smart_life" # tuya, smart_life, jinvoo_smart
Hi,
Thank you for the explanation. But i am Noob with Python/scripts. I use domoticz very long but i have no idea how to start a script or just set it up and run the output. I know how to change the credentials and put it in the right folder, but i have no idea what the commands are to start the script or where i can find the output...
Re: Python Plugin: TUYA
Posted: Tuesday 12 January 2021 20:44
by Xenomes
When you have edit and saved the file you can run the file by running 'python3 debug_discovery.py' the output will be displayed in the command-line-interface.
Re: Python Plugin: TUYA
Posted: Wednesday 13 January 2021 18:35
by Meeki
Thanks that was easy... eventuatly
Got credentials
{ 'access_token': 'EUheu1609586110102mlAAZQhy0lpJ48A',
'expires_in': 864000,
'refresh_token': 'EUheu1609586110102mlAAZw1nR80Bxuy',
'token_type': 'bearer'}
Getting devices
Got devices
{ 'header': {'code': 'SUCCESS', 'payloadVersion': 1},
'payload': { 'devices': [ { 'data': { 'brightness': '570',
'color_mode': 'white',
'color_temp': 7635,
'online': False,
'state': 'false'},
'dev_type': 'light',
'ha_type': 'light',
'icon': '
https://images.tuyaeu.com/smart/icon/ba ... 94800c.png',
'id': '30217610500291097a91',
'name': 'A60 806lm'},
{ 'data': { 'color_mode': 'colour',
'online': True,
'state': 'false'},
'dev_type': 'light',
'ha_type': 'light',
'icon': '
https://images.tuyaeu.com/smart/icon/ay ... af6b75.png',
'id': 'bfd13777feb40bfe129fcc',
'name': 'Led Strip Lights'},
{ 'data': {},
'dev_type': 'scene',
'ha_type': 'scene',
'id': 'DwzAA2IUA6IRYXaN',
'name': 'If Schema:07:00 Alle '
'Dagen,\\"Led Strip '
'Lights\\"On/Off:OFF'},
{ 'data': {},
'dev_type': 'scene',
'ha_type': 'scene',
'id': 'zWkFUoJotVjiIxB9',
'name': 'If Schema:19:00 Alle '
'Dagen,\\"Led Strip '
'Lights\\"On/Off:ON...'}],
'scenes': []}}
Here is the output
Re: Python Plugin: TUYA
Posted: Wednesday 13 January 2021 20:13
by Xenomes
Code: Select all
'data': {
'color_mode': 'colour',
'online': True,
'state': 'false'
},
'dev_type': 'light',
'ha_type': 'light',
'icon': 'https://images.tuyaeu.com/smart/icon/ay ... af6b75.png',
'id': 'bfd13777feb40bfe129fcc',
'name': 'Led Strip Lights'
}
This is the json part of you LED strip, the tuya api only reports color_mode, online, state there is no brightness or color_temp so there is noting that I can do about that. But I updated the plug-in so that when there is a light with missing data in the json it still creates an on/off device.
Re: Python Plugin: TUYA
Posted: Saturday 16 January 2021 8:17
by edwin1234
Still have problems login in.
I have checked 100 times for the correct credentials . I even logged out in the tuya app and manually typed in the same credentials, there is no problem. The app is closed if i try the test script
But with the test script i get these errors:
Getting credentials
Got credentials
{ 'errorMsg': 'Get accesstoken failed. Username or password error!',
'responseStatus': 'error'}
Traceback (most recent call last):
File "test.py", line 35, in <module>
payload = {"accessToken": auth_response["access_token"]}
KeyError: 'access_token'
Am i missing a file on the raspberry or could it be something else?
Hope someone can help
Thanks
Re: Python Plugin: TUYA
Posted: Saturday 16 January 2021 10:49
by Xenomes
edwin1234 wrote: ↑Saturday 16 January 2021 8:17
Traceback (most recent call last):
File "test.py", line 35, in <module>
I don´t understand where his is coming from, there is no mention of test.py anywhere in the code. Can you give more info on the system where u are running it on?
Re: Python Plugin: TUYA
Posted: Saturday 16 January 2021 13:37
by edwin1234
Sorry i renamed debug_discovery.py
To test.py that test script i mean
I run it on a raspberry pi 3b
Re: Python Plugin: TUYA
Posted: Sunday 17 January 2021 9:39
by Xenomes
I got only this error when i mistype my credentials.
Re: Python Plugin: TUYA
Posted: Sunday 17 January 2021 12:05
by edwin1234
Im sure I typed it correct
Re: Python Plugin: TUYA
Posted: Thursday 21 January 2021 20:14
by alexcasu
I've got the same problem.
Don't understand what's going bad.
Re: Python Plugin: TUYA
Posted: Friday 22 January 2021 13:14
by alexcasu
RESOLVED
- At the beginning I created a new account in Tuya via Google
- The authentication in Domoticz via Tuya plugin didn't work
- I closed the account in Tuya
- I created a new account with a different email and using a simple password (no special characters)
All works fine.
Re: Python Plugin: TUYA
Posted: Friday 22 January 2021 13:54
by edwin1234
I also use a google mailadres
Do you still use a googlemail adres in your new working account?
Re: Python Plugin: TUYA
Posted: Friday 22 January 2021 15:58
by Xenomes
alexcasu wrote: ↑Friday 22 January 2021 13:14
- I created a new account with a different email and using a simple password (no special characters)
Nice! I don't use have a Google email address but I have special characters in the password and that works fine. If this is a solution for edwin1234 too, then I added it to the readme on the github.
Re: Python Plugin: TUYA
Posted: Saturday 23 January 2021 19:16
by alexcasu
edwin1234 wrote: ↑Friday 22 January 2021 13:54
Do you still use a googlemail adres in your new working account?
Hi, I didn't use a google address for the second case and works fine.
Probably Google appplies some security policy that could create problem to the plugin.
Anyway, hope this solution is the right one for all.
Thank you.
Re: Python Plugin: TUYA
Posted: Saturday 23 January 2021 22:40
by edwin1234
Ok,
Thanks for your answer
I wil try it without a Gmail adress
Re: Python Plugin: TUYA
Posted: Sunday 24 January 2021 10:07
by edwin1234
I tried with a dummy account
And it worked
Thanks for your help
Re: Python Plugin: TUYA
Posted: Saturday 30 January 2021 20:54
by Afterburner
I buyed some Lidl Home stuff ( On/Off and Smartplug) to test with Domotics. I discovered it actually is Tuya stuff, so I installed the Smart Life app and configured the devices. Works fine. Installed the Xenomes Tuya plugin. It works fine, no errors, but, no devices. So I tried everything, reinstall app, new account without gmail, reinstall the plugin etc. Nothing helps. What happens here. I don't have new or special devices, but they are not visible.... Thanks for helping...
Log info:
After HW config.
2021-01-30 20:31:17.028 Status: (Tuya-Lidl stuff) Started.
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) TUYA plugin started
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) Debug logging mask set to: PYTHON CONNECTION
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'HardwareID':'19'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'HomeFolder':'/home/ubuntu/domoticz/plugins/Domoticz-TUYA-Plugin/'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'StartupFolder':'/home/ubuntu/domoticz/'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'UserDataFolder':'/home/ubuntu/domoticz/'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Database':'/home/ubuntu/domoticz/domoticz.db'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Language':'nl'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Version':'1.0.4'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Author':'Wagner Oliveira'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Name':'Tuya-Lidl stuff'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Port':'0'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Username':'---------'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Password':'---------'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Key':'tuya'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Mode1':'31'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Mode2':'tuya'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'Mode6':'18'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'DomoticzVersion':'2020.2'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'DomoticzHash':'b63341bc0'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) 'DomoticzBuildTime':'2020-04-26 13:47:55'
2021-01-30 20:31:18.414 (Tuya-Lidl stuff) Device count: 0
2021-01-30 20:31:18.415 (Tuya-Lidl stuff) in handlethread
2021-01-30 20:31:18.411 Status: (Tuya-Lidl stuff) Entering work loop.
2021-01-30 20:31:18.412 Status: (Tuya-Lidl stuff) Initialized version 1.0.4, author 'Wagner Oliveira'
Repeating.
2021-01-30 20:32:28.434 (Tuya-Lidl stuff) onHeartbeat called time=1612035148.4344158
2021-01-30 20:32:38.458 (Tuya-Lidl stuff) onHeartbeat called time=1612035158.4587584
2021-01-30 20:32:48.482 (Tuya-Lidl stuff) onHeartbeat called time=1612035168.4818926
Same result when I fill in Smart Life voor de appname in the HW config.
Re: Python Plugin: TUYA
Posted: Sunday 31 January 2021 10:06
by Xenomes
Afterburner wrote: ↑Saturday 30 January 2021 20:54
I buyed some Lidl Home stuff ( On/Off and Smartplug) to test with Domotics. I discovered it actually is Tuya stuff, so I installed the Smart Life app and configured the devices. Works fine. Installed the Xenomes Tuya plugin. It works fine, no errors, but, no devices. So I tried everything, reinstall app, new account without gmail, reinstall the plugin etc. Nothing helps. What happens here. I don't have new or special devices, but they are not visible.... Thanks for helping...
Can you post the result of debug_discovery.py in the tools directory. But i think that this zigbee products are not routed to the Tuya api used in the tuyaha liberty.
Re: Python Plugin: TUYA
Posted: Sunday 31 January 2021 22:56
by Afterburner
Thanks for responding so quickly.
Suprising respons:
2021-01-31 22:27:00.589 Error: EventSystem: Failed to execute python event script "Script #26"
2021-01-31 22:27:00.589 Error: EventSystem: Traceback (most recent call last):
2021-01-31 22:27:00.589 Error: EventSystem: File "<string>", line 2, in <module>
2021-01-31 22:27:00.589 Error: EventSystem: ModuleNotFoundError: No module named 'requests'
When I run the install command for tuyaha and requests, for the respons, see attachment including file-info.