Lights Off Timer: Jellyfin sleep timer that turns off Home Assistant lights
Jellyfin 12.2 plugin that adds a sleep-timer button next to the volume control in the web player (end of this episode/movie, or N minutes). When playback stops with the timer on, it calls a Home Assistant webhook that turns the lights off after a cooldown; starting playback cancels it. The repository doubles as a Jellyfin plugin repository: manifest.json at the root points at the release zips in dist/. build.sh builds in the .NET 10 SDK container and adds new versions to the manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
8d456442e6
15 files changed
+934
No files matched your search
@@ -0,0 +1,73 @@
|
||||
# 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://<your-home-assistant>/api/webhook/<webhook id>`
|
||||
- **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 `<script src="../LightsOffTimer/client.js">` to `/web/index.html` as it is served
|
||||
(nothing in the web client folder is modified).
|
||||
- `Web/client.js` adds the button and menu to the player and talks to the plugin API with the logged-in user's token:
|
||||
- `GET /LightsOffTimer/State` — timer for the caller's own session
|
||||
- `POST /LightsOffTimer/Set` — `{"mode": "end" | "minutes" | "off", "minutes": 30}`
|
||||
- A `client.js` placed in the plugin's data folder overrides the built-in one, for styling tweaks without rebuilding.
|
||||
|
||||
## Build / release
|
||||
|
||||
Only Docker is needed:
|
||||
|
||||
```sh
|
||||
./build.sh 1.0.3.0 "What changed"
|
||||
```
|
||||
|
||||
This builds in `mcr.microsoft.com/dotnet/sdk:10.0` against the `Jellyfin.Controller` 12.2.0 NuGet package,
|
||||
writes `dist/lightsofftimer_<version>.zip` and adds the version (with its MD5 checksum) to `manifest.json`.
|
||||
Commit and push `dist/` and `manifest.json`; Jellyfin servers using the repository will offer the update.
|
||||
For another Jellyfin version, change the package versions in the `.csproj` and run with `TARGET_ABI=x.y.z.0`.
|
||||
Reference in new issue
Block a user