Page 3 of 14

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 27 January 2023 14:20
by Xenomes
Varazir wrote: Friday 27 January 2023 14:11 I tried to just delete it from the device list but it didn't help.
That should do the trick. Normally then the device exist creation is skipped. I will do a test tonight.

Edit:
did you delete Plugin 13 TinyTuya ID = 43035720e098061d58bc unit = 1?

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 27 January 2023 14:32
by Varazir
Xenomes wrote: Friday 27 January 2023 14:20
Varazir wrote: Friday 27 January 2023 14:11 I tried to just delete it from the device list but it didn't help.
That should do the trick. Normally then the device exist creation is skipped. I will do a test tonight.

Edit:
did you delete Plugin 13 TinyTuya ID = 43035720e098061d58bc unit = 1?
I deleted it from the device list and turned the plugin off and on, did even restart domoticz but still got the same error.
Tried to turn off the plugin and delete the device and enabled the plugin again, still same error.

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 27 January 2023 14:41
by Xenomes
Varazir wrote: Friday 27 January 2023 14:32 I deleted it from the device list and turned the plugin off and on, did even restart domoticz but still got the same error.
Tried to turn off the plugin and delete the device and enabled the plugin again, still same error.
Is see the problem, forgot a piece of code that do the device exist creation skip procedure.

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 27 January 2023 15:02
by Xenomes
Xenomes wrote: Friday 27 January 2023 14:41
Varazir wrote: Friday 27 January 2023 14:32 I deleted it from the device list and turned the plugin off and on, did even restart domoticz but still got the same error.
Tried to turn off the plugin and delete the device and enabled the plugin again, still same error.
Is see the problem, forgot a piece of code that do the device exist creation skip procedure.
Pushed a update (no version change)

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 27 January 2023 17:35
by Varazir
Xenomes wrote: Friday 27 January 2023 15:02
Xenomes wrote: Friday 27 January 2023 14:41
Varazir wrote: Friday 27 January 2023 14:32 I deleted it from the device list and turned the plugin off and on, did even restart domoticz but still got the same error.
Tried to turn off the plugin and delete the device and enabled the plugin again, still same error.
Is see the problem, forgot a piece of code that do the device exist creation skip procedure.
Pushed a update (no version change)
Updated and restarted domoticz and no errors

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 27 January 2023 19:55
by Xenomes
Varazir wrote: Friday 27 January 2023 17:35 tarted domoticz and no errors
Ha, Great! But can you control the fan?

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 27 January 2023 19:59
by Varazir
No errors when I turned it on from DZ but didn't check if it started. I'll check when I get home again.

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Saturday 28 January 2023 7:47
by Varazir
Checked and it's working

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Saturday 28 January 2023 11:53
by Xenomes
Thanks for reporting back!

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 18:27
by frenchyyii
Hi everyone, first thanx for the plugin !!

I got some trouble to get it work on one of my DZ, I suspect a Python depency

some informations here:

Code: Select all

0 Error: Smartlife Tiny Tuya : Call to function 'onHeartbeat' failed, exception details:
2023-03-03 18:20:23.061 Error: Smartlife Tiny Tuya : Traceback (most recent call last):
2023-03-03 18:20:23.061 Error: Smartlife Tiny Tuya : File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 341, in onHeartbeat
2023-03-03 18:20:23.061 Error: Smartlife Tiny Tuya : _plugin.onHeartbeat()
2023-03-03 18:20:23.061 Error: Smartlife Tiny Tuya : File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 302, in onHeartbeat
2023-03-03 18:20:23.061 Error: Smartlife Tiny Tuya : if time.time() - last_update < 60 and testData == False:
2023-03-03 18:20:23.061 Error: Smartlife Tiny Tuya : NameError: name 'last_update' is not defined
DZ is last beta on a RPI4 with python 3.9.2:
Version: 2023.1 (build 15109)
Build Hash: b3211fe6d
Compile Date: 2023-03-01 16:44:49
dzVents Version: 3.1.8
Python Version: 3.9.2 (default, Mar 12 2021, 04:06:34) [GCC 10.2.1 20210110]
if someone can help

Regards
Eric

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 19:34
by Xenomes
I checkt the code, this could happen if there are no devices in the tuya account. Can you check that? Also try to press update on the hardware place.

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 20:19
by frenchyyii
Thanks for your fast response.
Concerning the tuya project, it is ok (22 devices)

But when desactivate reactivate the harware in domotics (with other project credentials) i have seen this message too:

Code: Select all

handleThread: Failed to parse: https://openapi.tuyaeu.com/v1.0/token?grant_type=1
I checked also Cloud Authorization IP Allowlist and it is off
Datacenter is central Europe
Also try to press update on the hardware place
Where . Iottuya or domoticz ?

Thanks
Oups another thing, now I'm on your dev branch but I've tried on the Master before and same reuslts

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 20:25
by Xenomes
frenchyyii wrote: Friday 03 March 2023 20:19 Where . Iottuya or domoticz ?
You already did it in Domoticz when deactivation reactivate the hardware.
frenchyyii wrote: Friday 03 March 2023 20:19 But when desactivate reactivate the harware in domotics (with other project credentials) i have seen this message too:

Code: Select all

handleThread: Failed to parse: https://openapi.tuyaeu.com/v1.0/token?grant_type=1
I checked also Cloud Authorization IP Allowlist and it is off
This error is coming from TinyTuya, there is something you forgot re walk the steps to setup the iot account.

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 20:30
by frenchyyii
if it helsp:

Code: Select all

 pip list
Package            Version
------------------ ---------
arandr             0.1.10
astroid            2.5.1
asttokens          2.0.4
automationhat      0.2.0
beautifulsoup4     4.9.3
blinker            1.4
blinkt             0.1.2
buttonshim         0.0.2
Cap1xxx            0.1.3
certifi            2020.6.20
chardet            4.0.0
charset-normalizer 3.0.1
click              7.1.2
colorama           0.4.4
colorzero          1.1
cryptography       3.3.2
cupshelpers        1.0
dbus-python        1.2.16
distlib            0.3.6
distro             1.5.0
docutils           0.16
drumhat            0.1.0
enum-compat        0.0.2
envirophat         1.0.0
ExplorerHAT        0.4.2
filelock           3.9.0
Flask              1.1.2
fourletterphat     0.1.0
gpiozero           1.6.2
html5lib           1.1
idna               2.6
isort              5.6.4
itsdangerous       1.1.0
jedi               0.18.0
Jinja2             2.11.3
lazy-object-proxy  0.0.0
logilab-common     1.8.1
lxml               4.6.3
MarkupSafe         1.1.1
mccabe             0.6.1
microdotphat       0.2.1
mote               0.0.4
motephat           0.0.3
mypy               0.812
mypy-extensions    0.4.3
netifaces          0.10.6
numpy              1.19.5
oauthlib           3.1.0
pantilthat         0.0.7
parso              0.8.1
pexpect            4.8.0
pgzero             1.2
phatbeat           0.1.1
pianohat           0.1.0
picamera           1.13
picamera2          0.3.8
pidng              4.0.9
piexif             1.1.3
piglow             1.2.5
pigpio             1.78
Pillow             8.1.2
pip                23.0.1
platformdirs       3.0.0
psutil             5.8.0
pycairo            1.16.2
pycparser          2.18
pycryptodome       3.17
pycups             2.0.1
pygame             1.9.6
Pygments           2.7.1
PyGObject          3.38.0
pyinotify          0.9.6
PyJWT              1.7.1
pylint             2.7.2
PyOpenGL           3.1.5
pyOpenSSL          20.0.1
PyQt5              5.15.2
PyQt5-sip          12.8.1
pyserial           3.5b0
pysmbc             1.0.23
python-apt         2.2.1
python-prctl       1.7
PyYAML             5.3.1
rainbowhat         0.1.0
reportlab          3.5.59
requests           2.28.2
requests-oauthlib  1.0.0
responses          0.12.1
roman              2.0.0
RPi.GPIO           0.7.0
RTIMULib           7.2.1
scrollphat         0.0.7
scrollphathd       1.2.1
Send2Trash         1.6.0b1
sense-hat          2.4.0
setuptools         67.4.0
simplejpeg         1.6.4
simplejson         3.17.2
six                1.11.0
skywriter          0.0.7
sn3218             1.2.7
soupsieve          2.2.1
spidev             3.5
ssh-import-id      5.10
thonny             4.0.1
tinytuya           1.10.3
toml               0.10.1
touchphat          0.0.1
tuyaha             0.0.11
twython            3.8.2
typed-ast          1.4.2
typing-extensions  3.7.4.3
unicornhathd       0.0.4
urllib3            1.26.5
v4l2-python3       0.3.1
virtualenv         20.20.0
webencodings       0.5.1
Werkzeug           1.0.1
wheel              0.34.2
wrapt              1.12.1

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 20:31
by frenchyyii
This error is coming from TinyTuya, there is something you forgot re walk the steps to setup the iot account.

cross messaging ... i don't think so but I'll check the autorisations

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 20:48
by frenchyyii
Everything seems to be ok, but when I check the API errors they are present with the project domoticz2 that is the one on this PI4
No error withe domoticz1 project that uses the other Pi4 with python 3.7

could'nt it be request module or somethink like that ?

Running the tool
same error with line24 added (sudo or not sudo ^^)

Code: Select all

debug_discovery: Failed to parse: https://openapi.tuyaeu.com/v1.0/token?grant_type=1 line 24

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 20:55
by Xenomes
Try running

Code: Select all

python3 -m tinytuya wizard
is something is missing you wil see it i hope.

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 21:01
by frenchyyii
Done

Code: Select all

{
    "apiKey": "xxxxxx",
    "apiSecret": "xxxxxx",
    "apiRegion": "eu",
    "apiDeviceID": xxxxx002462ab3d7a00"
}
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/requests/models.py", line 434, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/lib/python3/dist-packages/urllib3/util/url.py", line 394, in parse_url
    return six.raise_from(LocationParseError(source_url), None)
  File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: https://openapi.tuyaeu.com/v1.0/token?grant_type=1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/dist-packages/tinytuya/__main__.py", line 76, in <module>
    wizard.wizard(color=color, retries=retries, forcescan=force)
  File "/usr/local/lib/python3.9/dist-packages/tinytuya/wizard.py", line 137, in wizard
    cloud = tinytuya.Cloud( **config )
  File "/usr/local/lib/python3.9/dist-packages/tinytuya/Cloud.py", line 109, in __init__
    self._gettoken()
  File "/usr/local/lib/python3.9/dist-packages/tinytuya/Cloud.py", line 246, in _gettoken
    response_dict = self._tuyaplatform('token?grant_type=1')
  File "/usr/local/lib/python3.9/dist-packages/tinytuya/Cloud.py", line 205, in _tuyaplatform
    response = requests.get(url, headers=headers)
  File "/usr/local/lib/python3.9/dist-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 484, in prepare_request
    p.prepare(
  File "/usr/local/lib/python3.9/dist-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.9/dist-packages/requests/models.py", line 436, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: https://openapi.tuyaeu.com/v1.0/token?grant_type=1

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 21:27
by Xenomes
Can you try to update urllib3?

Code: Select all

pip3 install -U urllib3

Re: Python Plugin: Domoticz-TinyTUYA-Plugin (Cloud)

Posted: Friday 03 March 2023 22:12
by frenchyyii
python3 -m tinytuya wizard gives me:

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/dist-packages/tinytuya/__main__.py", line 76, in <module>
    wizard.wizard(color=color, retries=retries, forcescan=force)
  File "/usr/local/lib/python3.9/dist-packages/tinytuya/wizard.py", line 128, in wizard
    with open(CONFIGFILE, "w") as outfile:
PermissionError: [Errno 13] Permission denied: 'tinytuya.json'
but with sudo it seems to be ok except local devices are not found


it should be a owner problem... but now it's ok with DZ !!!
Thanks again 8-)