# Lights Off Timer — Jellyfin sleep timer that turns off your Home Assistant lights A Jellyfin plugin that adds a **sleep-timer button next to the volume control** in the web player. Pick *End of this episode/movie* (the default) or a number of minutes; when playback stops, the plugin tells **Home Assistant**, which turns the lights off after a cooldown (15 minutes by default). Starting playback again cancels the countdown. - **End of this episode/movie** — when the item finishes, the next autoplayed episode is stopped. - **15 / 30 / 45 / 60 / 90 minutes** (configurable) — playback is stopped when the time is up. - **Lights off** — on that stop (or when you stop playback yourself while the timer is on), Home Assistant starts its countdown and turns the lights off when it runs out. Built for **Jellyfin 12.2** (`targetAbi 12.2.0.0`). ## Install 1. In Jellyfin: **Dashboard → Plugins → Repositories → +** - Name: `Lights Off Timer` - URL: `https://git.piskot.si/nikrozman/jellyfin-lights-out-ha/raw/branch/master/manifest.json` 2. **Catalog → Lights Off Timer → Install**, then restart Jellyfin. 3. **Plugins → Lights Off Timer → Settings**: - **Home Assistant webhook URL** — `https:///api/webhook/` - **Lights off after (minutes)** — the cooldown, default 15 - **Timer presets** — minutes shown in the menu, default `15,30,45,60,90` - **Start the countdown on every playback stop** — off by default (only when the sleep timer was on) 4. Reload the Jellyfin web page. The moon button appears next to the volume slider while a video plays. ## Home Assistant Copy [`home-assistant/jellyfin_lights.yaml`](home-assistant/jellyfin_lights.yaml) into a package, set a long random `webhook_id`, reload **Timers** and **Automations**, and put the matching URL in the plugin settings. It creates `timer.movie_lights_off`, which you can show on a dashboard. The plugin sends: | When | Payload | |---|---| | Playback starts (any item) | `{"event": "started"}` | | Playback stops with the sleep timer on (or every stop, if enabled) | `{"event": "stopped", "cooldown_minutes": 15, "user": "…", "device": "…", "item": "…"}` | The webhook id is the only secret: anyone who knows it can trigger the automation. ## Limitations - The button only exists in **Jellyfin Web** (browser and Jellyfin Media Player). Native apps (Swiftfin, Android TV, Apple TV…) can't be extended by plugins. - Stopping playback uses Jellyfin's remote-control command, so the client must support remote control (Jellyfin Web does). - Timers live in memory: restarting Jellyfin clears them. ## How it works - `TimerManager` keeps a timer per playback session and listens to Jellyfin's `PlaybackStart` / `PlaybackStopped` events. It stops playback with `SendPlaystateCommand(Stop)` and posts to the webhook. - `ScriptInjection` adds `