Metadata-Version: 2.4
Name: Mopidy-JukeboxLights
Version: 1.0.1
Summary: Drive WLED LED strips from Mopidy album art
Author: King Butter
License-Expression: MIT
Project-URL: Homepage, https://github.com/kingbutter/mopidy-jukebox-lights
Project-URL: Issues, https://github.com/kingbutter/mopidy-jukebox-lights/issues
Project-URL: Source, https://github.com/kingbutter/mopidy-jukebox-lights
Keywords: mopidy,mopidy-extension,music,wled,led,esp32,lighting
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: No Input/Output (Daemon)
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Mopidy>=3.4
Requires-Dist: Pykka>=3.0
Requires-Dist: Pillow>=9.0
Requires-Dist: tornado>=6.0
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Dynamic: license-file

<img src="https://raw.githubusercontent.com/kingbutter/mopidy-jukebox-lights/main/media/banner.jpg" alt="Mopidy-JukeboxLights">

# Mopidy-JukeboxLights

[![PyPI](https://img.shields.io/pypi/v/Mopidy-JukeboxLights?label=PyPI&color=e0a020)](https://pypi.org/project/Mopidy-JukeboxLights/)
[![CI](https://github.com/kingbutter/mopidy-jukebox-lights/actions/workflows/ci.yml/badge.svg)](https://github.com/kingbutter/mopidy-jukebox-lights/actions)

A [Mopidy](https://mopidy.com/) extension that drives
[WLED](https://kno.wled.ge/) LED strips with colors pulled from the album art
of whatever is playing.

## What it does

- **Color from the sleeve.** Averaging album art gives brown every time.
  Instead this buckets pixels, discards anything too dark or too washed out to
  register as light, and scores the rest by pixel count weighted by
  saturation — so a small bright detail on a black sleeve still wins.
- **Two-color cabinets.** Picks an accent from the strongest hue at least
  ~29° away from the dominant, and paints nominated segments with it. A
  red-and-blue sleeve lights red and blue, not two shades of purple.
- **Event driven.** A Mopidy frontend actor listening for
  `track_playback_started`, so the lights change the instant the track does.
  Network calls run on a worker thread and never block Mopidy's event loop.
- **Idle and dark states.** Breathes amber when nothing is playing, and goes
  fully dark when a kiosk panel blanks — see `follow_display` below.

## Status page

Once running, `http://<your-host>:6680/jukeboxlights/` shows what the lights
are doing and, more usefully, *why* — whether WLED is reachable, which
segments were discovered, and whether the strip is following music, breathing
amber, or dark because the kiosk panel blanked. It also has a button to cycle
red/green/blue/amber for checking wiring without needing to play anything.

## Installation

```sh
python3 -m pip install Mopidy-JukeboxLights
```

## Configuration

```ini
[jukeboxlights]
enabled = true
wled_host = 172.20.25.44       # IP or host:port of your WLED device
brightness = 160               # 1-255
idle_after = 45                # seconds of silence before the idle effect
idle_color = amber             # name, hex, or r,g,b
accent_segments = 1,2,3        # segment ids that get the accent color
follow_display = true
display_flag = /run/jukebox/display-off
```

Segments are read from WLED at startup, so a strip run in one uncut piece with
hidden stretches behind a door frame works without any config here — define
the visible runs as WLED segments and this follows them.

### Idle color

`idle_color` accepts a name, a hex string, or an `r,g,b` triplet — `amber`,
`#f0a830`, `f0a830`, `#fa3` and `240,168,48` are all the same colour. Named
options: `amber`, `warm-white`, `candle`, `gold`, `red`, `oxblood`, `pink`,
`purple`, `blue`, `cyan`, `teal`, `green`, `lime`, `white`.

The status page has a swatch grid and a colour picker that apply immediately,
so you can try colours against the actual cabinet before committing one to
`mopidy.conf`. Changes made there are not persisted — the config file stays
the source of truth across restarts, and the page shows the line to paste.

### Turning the lights off with the screen

If something else on the machine creates the file named by `display_flag` when
a kiosk display blanks, the strip goes fully dark rather than breathing — but
only while nothing is playing. Remove the file and it comes back. Set
`follow_display = false` to ignore this entirely.

## Project resources

- [Source code](https://github.com/kingbutter/mopidy-jukebox-lights)
- [Issue tracker](https://github.com/kingbutter/mopidy-jukebox-lights/issues)

## Credits

- Original author: [King Butter](https://github.com/kingbutter)
- Current maintainer: [King Butter](https://github.com/kingbutter)
x
