#python_script not allowed to import websocket
1 messages · Page 1 of 1 (latest)
It is not possible to use Python imports with this integration. If you want to do more advanced scripts, you can take a look at AppDaemon or pyscript
You should look into PyScript if you want something more advanced
But it worked 'till a couple of weeks ago 🫠
"by accident", perhaps
Maybe.
I'll add PyScript to my to do list then, thanks!
I was reading a bit of documentation about the implementation of Websocket APIs in Home Assistant when i stumbled on this chinese doc page where they mentions:
Python - CLI client using asyncws
(NB: in the english version this reference seems to be missing)
So I tried to rewrite my script using asyncio and asyncws instead of websocket, but it doesn't seems that the libraries are shipped with HA anymore:
stdout: ""
stderr: |-
Traceback (most recent call last):
File "/config/python_scripts/hyperion_add_remote_source.py", line 3, in <module>
import asyncws
ModuleNotFoundError: No module named 'asyncws'
returncode: 1
Any other suggestions before I'll add another integration to my collection?
websockets has never been able to import into python scripts. If your script worked, then that script somehow found a loophole.
suffice to say, use pyscript, you won't have any options with python_scripts unless you look for another loophole (assuming it existed in the first place)
Is there any other route, even if using other languages? The script is quite simple, I can manage to port it over.