Xenomes / Domoticz-TUYA-Plugin

Implements the special Tuya Home Assistant API.
22 stars 8 forks source link

Error initializing plugin #41

Closed lamama1234 closed 1 year ago

lamama1234 commented 1 year ago

After getting an error when trying to switch off a Tuya switch I disabled/enabled the plugin in Domoticz and got the following errors:

2023-03-30 08:43:52.261 Error: Tuya: (tuya) failed to load 'plugin.py', Python Path used was 'C:\Program Files (x86)\Domoticz\plugins\Domoticz-TUYA-Plugin-master\;C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\python38.zip;C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\Lib\;C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\DLLs\;C:\Program Files (x86)\Domoticz;C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32;C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\lib\site-packages'.
2023-03-30 08:43:52.264 Error: Tuya: Traceback (most recent call last):
2023-03-30 08:43:52.264 Error: Tuya: File "C:\Program Files (x86)\Domoticz\plugins\Domoticz-TUYA-Plugin-master\plugin.py", line 65, in <module>
2023-03-30 08:43:52.264 Error: Tuya: import tuyaha
2023-03-30 08:43:52.264 Error: Tuya: File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tuyaha\__init__.py", line 2, in <module>
2023-03-30 08:43:52.264 Error: Tuya: from .tuyaapi import TuyaApi
2023-03-30 08:43:52.264 Error: Tuya: File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tuyaha\tuyaapi.py", line 4, in <module>
2023-03-30 08:43:52.264 Error: Tuya: import requests
2023-03-30 08:43:52.265 Error: Tuya: File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\__init__.py", line 48, in <module>
2023-03-30 08:43:52.265 Error: Tuya: from charset_normalizer import __version__ as charset_normalizer_version
2023-03-30 08:43:52.265 Error: Tuya: File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\lib\site-packages\charset_normalizer\__init__.py", line 24, in <module>
2023-03-30 08:43:52.265 Error: Tuya: from .api import from_bytes, from_fp, from_path
2023-03-30 08:43:52.265 Error: Tuya: File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\lib\site-packages\charset_normalizer\api.py", line 5, in <module>
2023-03-30 08:43:52.265 Error: Tuya: from .cd import (
2023-03-30 08:43:52.265 Error: Tuya: File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python38-32\lib\site-packages\charset_normalizer\cd.py", line 9, in <module>
2023-03-30 08:43:52.265 Error: Tuya: from .md import is_suspiciously_successive_range
2023-03-30 08:43:52.265 Error: Tuya: SystemError: initialization of md__mypyc did not return an extension module

Running Domoticz 2023.1 stable, Python 3.8, Win7, Smart Life

Xenomes commented 1 year ago

Cording your log tuyaha in not installed. See readme for install instructions.

lamama1234 commented 1 year ago

Cording your log tuyaha in not installed. See readme for install instructions.

Your plugin used to work ok till now. Any chance that tuyaha was uninstalled unintentionally?

Xenomes commented 1 year ago

No normally not, did you do a Python u[update?

lamama1234 commented 1 year ago

No normally not, did you do a Python u[update?

I updated from 3.4 to 3.8 but that was over 2 months ago. I did install tuyaha when upgrading to 3.8

Xenomes commented 1 year ago

Strange... the plugin now working?

lamama1234 commented 1 year ago

Strange... the plugin now working?

I will try again when I get back home = restarting Domoticz + re-installing Tuyaha

Xenomes commented 1 year ago

👍🏻

lamama1234 commented 1 year ago

@Xenomes

A simple restart of Domoticz fixed it, i did not install Tuyaha again. Any idea why it happened?

Tnx

Xenomes commented 1 year ago

The problem appeaser when at hardware is update pressed.

What are you version of requests and charset-normalizer? sudo pip3 show requests charset-normalizer

Write down the versions and up or downgrade to sudo pip3 requests==2.23.0 charset-normalizer==3.0.1

lamama1234 commented 1 year ago

I had requests 2.28.2 and charset 3.1.0 Just downgraded and hoping for the best. Tnx!

Xenomes commented 1 year ago

OK, Let me know the results, Thanks!

lamama1234 commented 1 year ago

So far so good! I'll keep you posted. Thanks!

lamama1234 commented 1 year ago

So I'm not getting the above errors anymore however my single Tuya device now cannot be controlled any more using Domoticz-TUYA-Plugin. Smart Life App is able to control the device (it's a motorized smart-valve-switch). I tried restarting Domoticz but it didn't help.

Attaching my Domoticz log + error while trying to close/open the valve.

Clipboard-1 Clipboard-2

Xenomes commented 1 year ago

Hi Lamama1234, It looks like you are not on the latest version, the error in the log on line 209 is a comment text so that do not match.

lamama1234 commented 1 year ago
2023-04-16 21:08:07.345 Error: Tuya: handleThread: line 211
2023-04-16 21:15:26.185 Error: Tuya: Command for DeviceID=bff2d65fdf114faxxxxxxxxx but device is not available.

Updated to latest, valve still not working and now getting the above.

This is what I'm geting during init:

2023-04-16 21:05:45.389 Tuya: TUYA plugin started
2023-04-16 21:05:45.389 Tuya: Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE
2023-04-16 21:05:45.389 Tuya: 'HardwareID':'14'
2023-04-16 21:05:45.390 Tuya: 'HomeFolder':'C:\Program Files (x86)\Domoticz\plugins\Domoticz-TUYA-Plugin-master\'
2023-04-16 21:05:45.390 Tuya: 'StartupFolder':'C:\Program Files (x86)\Domoticz\'
2023-04-16 21:05:45.390 Tuya: 'UserDataFolder':'C:\Program Files (x86)\Domoticz\'
2023-04-16 21:05:45.390 Tuya: 'Database':'C:\Program Files (x86)\Domoticz\domoticz.db'
2023-04-16 21:05:45.391 Tuya: 'Language':'en'
2023-04-16 21:05:45.391 Tuya: 'Version':'1.0.15'
2023-04-16 21:05:45.391 Tuya: 'Author':'Wagner Oliveira contributed Xenomes'
2023-04-16 21:05:45.392 Tuya: 'Name':'Tuya'
2023-04-16 21:05:45.392 Tuya: 'Port':'0'
2023-04-16 21:05:45.392 Tuya: 'Username':'xxxxxxxxx@xxxxxxxxx.com'
2023-04-16 21:05:45.392 Tuya: 'Password':'xxxxxxxxxxxx'
2023-04-16 21:05:45.392 Tuya: 'Key':'tuya'
2023-04-16 21:05:45.392 Tuya: 'Mode1':'972'
2023-04-16 21:05:45.393 Tuya: 'Mode2':'smart_life'
2023-04-16 21:05:45.393 Tuya: 'Mode6':'-1'
2023-04-16 21:05:45.393 Tuya: 'DomoticzVersion':'2023.1'
2023-04-16 21:05:45.393 Tuya: 'DomoticzHash':'xxxxxxxxxxxx'
2023-04-16 21:05:45.393 Tuya: 'DomoticzBuildTime':'2023-02-14 16:06:40'
2023-04-16 21:05:45.394 Tuya: Device count: 1
2023-04-16 21:05:45.394 Tuya: Device: 1 - ID: 459, Name: 'Water Main Valve', nValue: 1, sValue: 'On'
2023-04-16 21:05:45.394 Tuya: Device ID: '459'
2023-04-16 21:05:45.394 Tuya: Device Name: 'Water Main Valve'
2023-04-16 21:05:45.394 Tuya: Device nValue: 1
2023-04-16 21:05:45.394 Tuya: Device sValue: 'On'
2023-04-16 21:05:45.394 Tuya: Device LastLevel: 0
2023-04-16 21:05:45.395 Tuya: in handlethread
2023-04-16 21:05:45.396 Tuya: Acquiring GIL for 'onStartCallback'
2023-04-16 21:05:45.447 Tuya: Pushing 'onHeartbeatCallback' on to queue
2023-04-16 21:05:45.497 Tuya: Processing 'onHeartbeatCallback' message
2023-04-16 21:05:45.497 Tuya: Acquiring GIL for 'onHeartbeatCallback'
2023-04-16 21:05:45.497 Tuya: Calling message handler 'onHeartbeat' on 'module' type object.
2023-04-16 21:05:45.498 Tuya: onHeartbeat called time=1681668345.4989667
2023-04-16 21:05:45.498 Tuya: in handlethread
2023-04-16 21:05:45.499 Tuya: Device count: 1
2023-04-16 21:05:45.499 Tuya: Acquiring GIL for 'onHeartbeatCallback'
2023-04-16 21:05:55.014 Tuya: Pushing 'onHeartbeatCallback' on to queue
2023-04-16 21:05:55.064 Tuya: Processing 'onHeartbeatCallback' message
2023-04-16 21:05:55.064 Tuya: Acquiring GIL for 'onHeartbeatCallback'
2023-04-16 21:05:55.064 Tuya: Calling message handler 'onHeartbeat' on 'module' type object.
2023-04-16 21:05:55.064 Tuya: Acquiring GIL for 'onHeartbeatCallback'

Sorry for the bother! and tnx in advance

Xenomes commented 1 year ago

Line 211 is the tuya.init did you update tuyaha to the latest?

lamama1234 commented 1 year ago
C:\Windows\system32>pip show tuyaha
Name: tuyaha
Version: 0.0.11
Summary: A Python library that implements a Tuya API endpoint that was specially
 designed for Home Assistant
Home-page: https://github.com/PaulAnnekov/tuyaha
Author: Pavlo Annekov and original Tuya authors
Author-email: paul.annekov@gmail.com
License: MIT
Location: c:\users\xxxxxxxxx\appdata\local\programs\python\python38-32\lib\site-packages
Requires: requests
Required-by:
lamama1234 commented 1 year ago

@Xenomes

I just realized I had Python 3.5 remains on my Path variable. So I cleaned all 3.5 out of my path, but still seeing that line 211 error.

When I tried to re-install tuyaha I got:

C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\Scripts>pip install toyaha
ERROR: Could not find a version that satisfies the requirement toyaha (from versions: none)
ERROR: No matching distribution found for toyaha

When using verbose install I get:

C:\Users\xxxxxxxxxx\Documents\tuyaha-master\tuyaha-master>pip3 -vvv install toyaha

Using pip 23.1 from C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip (python 3.8)
Non-user install because site-packages writeable
Created temporary directory: C:\Users\xxxxxxxxxx\AppData\Local\Temp\pip-build-tracker-jup4m24m
Initialized build tracking at C:\Users\xxxxxxxxxx\AppData\Local\Temp\pip-build-tracker-jup4m24m
Created build tracker: C:\Users\xxxxxxxxxx\AppData\Local\Temp\pip-build-tracker-jup4m24m
Entered build tracker: C:\Users\xxxxxxxxxx\AppData\Local\Temp\pip-build-tracker-jup4m24m
Created temporary directory: C:\Users\xxxxxxxxxx\AppData\Local\Temp\pip-install-qbchw0hj
Created temporary directory: C:\Users\xxxxxxxxxx\AppData\Local\Temp\pip-ephem-wheel-cache-xs2j7__o
1 location(s) to search for versions of toyaha:
* https://pypi.org/simple/toyaha/
Fetching project page and analyzing links: https://pypi.org/simple/toyaha/
Getting page https://pypi.org/simple/toyaha/
Found index url https://pypi.org/simple/
Looking up "https://pypi.org/simple/toyaha/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/toyaha/ HTTP/1.1" 404 13
Status code 404 not in (200, 203, 300, 301, 308)
Could not fetch URL https://pypi.org/simple/toyaha/: 404 Client Error: Not Found for url: https://pypi.org/simple/toyaha/ - skipping
Skipping link: not a file: https://pypi.org/simple/toyaha/
Given no hashes to check 0 links for project 'toyaha': discarding no candidates
ERROR: Could not find a version that satisfies the requirement toyaha (from versions: none)
ERROR: No matching distribution found for toyaha
Exception information:
Traceback (most recent call last):
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 174, in _add_to_criteria
    raise RequirementsConflicted(criterion)
pip._vendor.resolvelib.resolvers.RequirementsConflicted: Requirements conflict:
SpecifierRequirement('toyaha')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 399, in resolve
    raise ResolutionImpossible(e.criterion.information)
pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('toyaha'), parent=None)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\cli\base_command.py", line 169, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\cli\req_command.py", line 248, in wrapper
    return func(self, options, args)
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\commands\install.py", line 377, in run
    requirement_set = resolver.resolve(
  File "C:\Users\xxxxxxxxxx\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 101, in resolve
    raise error from e
pip._internal.exceptions.DistributionNotFound: No matching distribution found for toyaha
Remote version of pip: 23.1
Local version of pip:  23.1
Was pip installed by pip? True
Removed build tracker: 'C:\\Users\\xxxxxxxxxx\\AppData\\Local\\Temp\\pip-build-tracker-jup4m24m'

So I tried to force install tuyaha whl:

C:\Users\xxxxxxxxxx\Documents\tuyaha-master\tuyaha-master>pip install --force-reinstall tuyaha-0.0.11-py3-none-any.whl
Processing c:\users\xxxxxxxxxx\documents\tuyaha-master\tuyaha-master\tuyaha-0.0.11-py3-none-any.whl
Collecting requests (from tuyaha==0.0.11)
  Using cached requests-2.28.2-py3-none-any.whl (62 kB)
Collecting charset-normalizer<4,>=2 (from requests->tuyaha==0.0.11)
  Using cached charset_normalizer-3.1.0-cp38-cp38-win32.whl (89 kB)
Collecting idna<4,>=2.5 (from requests->tuyaha==0.0.11)
  Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1 (from requests->tuyaha==0.0.11)
  Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
     -------------------------------------- 140.9/140.9 kB 1.0 MB/s eta 0:00:00
Collecting certifi>=2017.4.17 (from requests->tuyaha==0.0.11)
  Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests, tuyaha
  Attempting uninstall: urllib3
    Found existing installation: urllib3 1.25.11
    Uninstalling urllib3-1.25.11:
      Successfully uninstalled urllib3-1.25.11
  Attempting uninstall: idna
    Found existing installation: idna 2.10
    Uninstalling idna-2.10:
      Successfully uninstalled idna-2.10
  Attempting uninstall: charset-normalizer
    Found existing installation: charset-normalizer 3.0.1
    Uninstalling charset-normalizer-3.0.1:
      Successfully uninstalled charset-normalizer-3.0.1
  Attempting uninstall: certifi
    Found existing installation: certifi 2022.12.7
    Uninstalling certifi-2022.12.7:
      Successfully uninstalled certifi-2022.12.7
  Attempting uninstall: requests
    Found existing installation: requests 2.23.0
    Uninstalling requests-2.23.0:
      Successfully uninstalled requests-2.23.0
  Attempting uninstall: tuyaha
    Found existing installation: tuyaha 0.0.11
    Uninstalling tuyaha-0.0.11:
      Successfully uninstalled tuyaha-0.0.11
Successfully installed certifi-2022.12.7 charset-normalizer-3.1.0 idna-3.4 requests-2.28.2 tuyaha-0.0.11 urllib3-1.26.15

But pip nor pip3 "show" doesn't confirm an existing tuyaha:

C:\Users\xxxxxxxxxx\Documents\tuyaha-master\tuyaha-master>pip show toyaha
WARNING: Package(s) not found: toyaha

Any help will be much appreciated!

Xenomes commented 1 year ago

Normal you don't need to go to the C:\Users\xxxxxxxxxx\Documents\tuyaha-master\tuyaha-master path. Also there is a typo you use toyaha but it is tuyaha.

lamama1234 commented 1 year ago

you were right about the typo, it now confirms that tuyaha is installed. i'm not seeing the line 211 error anymore but pressing the switch doesn't work and produces a similar error to before:

2023-04-17 21:14:11.678 Error: Tuya: Command for DeviceID=bff2d6f114fxxxxxxxxxx but device is not available.