1

我正在使用 Home Assistant,我想每 30 分钟执行一次 Python 脚本。为此,我使用带有@time_trigger("cron(...)")注释的 pyscript。

但是,我的脚本连接到 websocket(连接到外部 URL,而不是 HASS 的 URL)并且我收到以下错误:

2022-02-01 18:48:00 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for pyscript doing I/O at custom_components/pyscript/eval.py, line 1899: return func(*args, **kwargs)
2022-02-01 18:48:00 ERROR (MainThread) [custom_components.pyscript.file.tydomCalls.test_service] Exception in <file.tydomCalls.test_service> line 179:
        conn.request("GET", "/mediation/client?mac={}&appli=1".format(mac), None, httpHeaders)
                                                                                  ^
RuntimeError: I/O must be done in the executor; Use `await hass.async_add_executor_job()` at custom_components/pyscript/eval.py, line 1899: return func(*args, **kwargs)

所以我想知道如果 pyscript 不允许,我该如何执行我的脚本?

4

0 回答 0