Spotify Display Guide:

1. Put files in place

---

mkdir -p /home/pi/cassette-light
cd /home/pi/cassette-light

# Copy your run.py and .env into this folder

2. Create Python venv and install deps (one-time)

---

sudo apt update
sudo apt install -y python3 python3-venv python3-pip
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install pillow python-dotenv requests spotipy
pip install RPi.GPIO || true

3. Edit .env (set your values)

---

nano .env

* Set WLED_IP=192.168.xx.yy
* Set:
  SPOTIFY_CLIENT_ID=YOUR_CLIENT_ID
  SPOTIFY_CLIENT_SECRET=YOUR_CLIENT_SECRET
  SPOTIFY_REDIRECT_URI=[https://lukethemaker.com/spotify/callback](https://lukethemaker.com/spotify/callback)
  Save and exit (Ctrl+O, Enter, Ctrl+X).

4. Do FIRST RUN manually to complete Spotify auth

---

cd /home/pi/cassette-light
source .venv/bin/activate
python run.py

* The script prints an authorization URL. Open it in a browser.
* Approve, you will land at:
  [https://lukethemaker.com/spotify/callback?code=...&state=](https://lukethemaker.com/spotify/callback?code=...&state=)...
* Copy the FULL URL from the browser address bar.
* Paste that FULL URL back into the terminal when asked.
* When album art starts working, press Ctrl+C to stop. A file named .spotipy_cache was created.

5. Create a systemd service

---

sudo nano /etc/systemd/system/cassette.service

Paste this EXACT content (change pi to your username if needed):
[Unit]
Description=Cassette Light (Spotify -> WLED)
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/cassette-light
ExecStart=/home/pi/cassette-light/.venv/bin/python /home/pi/cassette-light/run.py
Restart=always
RestartSec=3
Environment=PYTHONUNBUFFERED=1

[Install]
WantedBy=multi-user.target

Save and exit (Ctrl+O, Enter, Ctrl+X).

6. Enable and start the service

---

sudo systemctl daemon-reload
sudo systemctl enable cassette.service
sudo systemctl start cassette.service

7. Check status and logs

---

systemctl status cassette.service

# press q to exit

# live logs (Ctrl+C to stop viewing)

journalctl -u cassette.service -f

8. Useful commands

---

# Restart after editing files

sudo systemctl restart cassette.service

# Stop / Start

sudo systemctl stop cassette.service
sudo systemctl start cassette.service

# Disable autostart

sudo systemctl disable cassette.service

9. Common fixes

---

* If it says redirect mismatch during auth:
  Make sure SPOTIFY_REDIRECT_URI in .env is EXACTLY:
  [https://lukethemaker.com/spotify/callback](https://lukethemaker.com/spotify/callback)
  and the same value is added in your Spotify app’s Redirect URIs.

* If you used a different user than pi:
  Edit /etc/systemd/system/cassette.service and change:
  User=YOUR_USER
  Group=YOUR_USER
  WorkingDirectory=/home/YOUR_USER/cassette-light
  ExecStart=/home/YOUR_USER/cassette-light/.venv/bin/python /home/YOUR_USER/cassette-light/run.py
  Then run:
  sudo systemctl daemon-reload
  sudo systemctl restart cassette.service

* If no LEDs change:
  Check WLED_IP in .env and that the Pi and WLED are on the same network.
