FlagX / ha-ledvance-tuya-resync-localkey

pyscript for homeassistant to resync local keys from private tuya api
MIT License
108 stars 17 forks source link

ModuleNotFoundError: No module named 'pyscript_modules' #14

Closed typxxi closed 1 year ago

typxxi commented 1 year ago

First I have installed the Pyscript Integration on my Pi 3 HASS installation via HACS. Then I have added and configured the Pyscript Integration and went on the pi to the terminal (Hass installation) and installed the requirement

pip install pycryptodome

followed by a full reboot to be on the safe side.

Finally I run the script and still got the message of a missing module:

➜ ~ python print-local-keys.py Traceback (most recent call last): File "/root/print-local-keys.py", line 6, in from pyscript_modules.tuya.api import TuyaAPI ModuleNotFoundError: No module named 'pyscript_modules'

The only success is that local tuya was able to find and show the ledvanced smart+ plug (right IP adress) but without a key no chance to continue.

Here is the ls of my config and custom components dir which includes pyscript and tuya. The system has been setup from scratch yesterday as HASS system image

FlagX commented 1 year ago

@typxxi seems like you forgot to copy the pyscript_modules directory to the config directory.

typxxi commented 1 year ago

@typxxi seems like you forgot to copy the pyscript_modules directory to the config directory.

thanks, will check it in 1 hour

typxxi commented 1 year ago

Sorry, but I new to HA HASS and had been working previously with HA core on a Pi where things had been quite different.

So now I have installed github on HA, then i logged into my account and among other projects I got the offer for FlagX which I then chose. I guess I have now installed the code but I am still unsure cause I looked into config / customs and could not find anything. I can see the FlagX entities or sensor (12 or so), but I am simply do not know what to do next.

Do I still have to download the github code with

gh repo clone FlagX/ha-ledvance-tuya-resync-localkey

And if so into which directory ? I ususally would go into that directory and then start the gh repo clone FlagX/ha-ledvance-tuya-resync-localkey

command.

Sorry, but first time that i am using HASS after I had been spending a week with HA as a docker running on SonOff ihost as local replacement of the cloud. did not work out at a ll cause no terminal no access and lot of issues. Therefore I am the 3rd day on HASS.

thanks a lot

FlagX commented 1 year ago

If you just want the local keys you do not need install/copy anything from this repository to your Pi or wherever your home assistant installation is. You can download the repo to PC/Mac/Workstation (https://github.com/FlagX/ha-ledvance-tuya-resync-localkey/archive/refs/heads/main.zip) and execute the script from there. You need to have installed python though.

typxxi commented 1 year ago

OK, I installed it on a Windows machine in a directory and started the script with:

python print-local-keys.py

and got the keys even from a remote LED VANCE plug far away so it got the data out of the cloud.

But then I struggled again in the local tuya integration cause I do not get any further than local tuya integration

image

I used the device ID and name from the script result by copying and pasting it but still get the message regardless which protocol I had chosen . Did I miss anything else ?

FlagX commented 1 year ago

I have no Ledvance plugs to compare, but take a look in the logs (Settings -> System -> Logs) and check if there is a more detailed error message.

typxxi commented 1 year ago

Really ? I had thought you had posted a comment in the HA forum in the LEDvance HA topic .

But maybe this log might a help a bit more even though I have a question first:

In my previous message there is a line at the bottom about the log and that it has to be activated in the configuration.yaml

Do you know which entry is meant so that I could check that ?

Here is the log from settings - system - logs

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:450
Integration: LocalTuya integration (documentation, issues)
First occurred: 03:57:40 (1 occurrences)
Last logged: 03:57:40

[011...0b2] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 863, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 795, in status
    status = await self.exchange(DP_QUERY)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 769, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 450, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:450
Integration: LocalTuya integration (documentation, issues)
First occurred: 03:57:40 (1 occurrences)
Last logged: 03:57:40

[011...0b2] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 863, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 795, in status
    status = await self.exchange(DP_QUERY)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 769, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 450, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError 
typxxi commented 1 year ago

I have installed this local tuya thing via HACs if I remember right. I was able to retrieve my tuya plugs data and I was also able to achieve the LEDVANCE login from the HA UI

Maybe there is another log ?

thx

FlagX commented 1 year ago

Hmm, I was hoping for something more obvious in the logs. I have no idea what the problem could be. Maybe open an issue at https://github.com/rospogrigio/localtuya or someone at https://community.home-assistant.io/ can help you.