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

What to do in case of SyntaxError: 'await' outside async function #13

Closed typxxi closed 1 year ago

typxxi commented 1 year ago

UPDATE: First I tried the sync script even though I wanted to print them out. Then I found the right script print-local-keys.py and now I get a missing module error: "ModuleNotFoundError: No module named 'pyscript_modules' "

FIRST TRY: sync_tuya_keys.py I am running the script on a windows 10 machine from the powershell locally. I have installed all the requirements like the crypto thing.

I cross checked the password and user id so that this is not the reason.

I have also tried api = TuyaAPI("whatever@gmail.xyz", "password") and with these [] brackets api = TuyaAPI(["whatever@gmail.xyz", "password"])

but no success cause I still get this message

File "....LocalTuyaKeys\sync_tuya_keys.py", line 12 await hass.async_add_executor_job(api.login) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'await' outside async function

Any ideas ? I just wanna read the 2 keys to use them in local tuya for LEDvance energy consumption monitoring within HA

Thanks a lot !

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

FlagX commented 1 year ago

Hi @typxxi, you need to clone or download the entire repo and run the script (print-local-keys.py) inside that directory as it needs the modules.