I’m really pulling my hair over how to implement pyscript to utilize a websocket module (this one). I’m using HaOS/Odroid. I’ve confirmed that the module works as intended, by launching it through the Advanced SSH add-on, where one can access python3.
As to the pyscript implementation, I have successfully installed it. The module in point is in [config]/pyscript/modules/
. I have then created a file in /pyscript/
called blabla.py
with the following code, which is not working:
from sungrow-websocket import SungrowWebsocket
host = "192.168.1.35"
sg = SungrowWebsocket(host)
def data():
sg.get_data()
return allt
@service
def sgdata():
log.info(f"sgdata testar!")
allt = data()
log.info(f"{allt}")
state.set(input_text.sgdatan, allt)
Log throws me this:
Exception in </config/pyscript/blabla.py> line 1: from sungrow-websocket import SungrowWebsocket ^ SyntaxError: invalid syntax (blabla.py, line 1)
Could someone please help me on this one?