pyscript
pyscript copied to clipboard
Error on call http://172.30.32.1:8123/api/config: Watchdog found a problem with Home Assistant API!
I'm start this script /config/pyscript/expample_spoti.py:
import os
import sys
from dotenv import load_dotenv
import spotipy
from spotipy.oauth2 import SpotifyOAuth
@service
def spotipy_me():
"""sptipy_world example using pyscript."""
path = sys.path[1]+'/pyscript/.env'
load_dotenv(path)
sp = spotipy.Spotify(auth_manager=SpotifyOAuth())
device_id = os.getenv('SPOTIPY_DEVICE_ID')
sp.pause_playback(device_id)
with /config/pyscript/requirements.txt :
spotipy
python-dotenv
and it's broken Home Assistant - UI not response some minutes
22-01-13 10:29:56 ERROR (MainThread) [supervisor.homeassistant.api] Error on call http://172.30.32.1:8123/api/config: 22-01-13 10:29:56 ERROR (MainThread) [supervisor.misc.tasks] Watchdog found a problem with Home Assistant API!
It's likely that spotipy does blocking I/O, which stalls the main event loop. See the docs here.
I'd recommend using async-spotify, which is designed for non-blocking async operation, or some other package that supports async operation.