Jellyfin Control
A robust skill to control Jellyfin playback and TV power via CLI.
Features
- - 🎯 One-Command Play:
tv play "Breaking Bad" — turns on TV, launches Jellyfin, finds the next episode, and plays it. - Smart Resume: Automatically finds the next unplayed episode for series.
- Resume Position: Resumes Movies/Episodes exactly where left off (with
Seek fallback for LG WebOS/Tizen). - Device Discovery: Auto-detects controllable sessions (TVs, Phones, Web).
- Remote Control: Full playback control (play, pause, stop, next, prev, volume, mute).
- TV Power & Apps: Turn TV on/off, launch apps — works with or without Home Assistant.
- Two TV Backends: Home Assistant integration or direct WebOS (LG TVs, no HA needed).
- Android TV Support: Direct ADB backend for Chromecast w/ Google TV, Nvidia Shield, Fire TV, Mi Box — no HA needed.
- Three connection modes: Home Assistant (any TV), direct WebOS (LG), direct ADB (Android TV/Fire TV).
Quick Start
Minimal setup (Jellyfin only, no TV control)
CODEBLOCK0
With Home Assistant (recommended for TV control)
CODEBLOCK1
Direct WebOS (LG TV, no Home Assistant needed)
CODEBLOCK2
First time with WebOS direct: The TV will show a pairing prompt. Accept it and save the TV_CLIENT_KEY the skill prints — add it to your env to skip the prompt next time.
Direct ADB (Android TV / Fire TV / Chromecast with Google TV, no HA needed)
CODEBLOCK3
First time with ADB: Enable Developer Options on your TV (Settings → About → tap Build Number 7 times), then enable Network/USB debugging. First connection will show "Allow debugging?" on the TV — accept it. Requires adb installed on the OpenClaw host (sudo apt install adb).
Environment Variables
Jellyfin (required)
| Variable | Required | Description |
|---|
| INLINECODE5 | Yes | Base URL of your Jellyfin server, e.g. INLINECODE6 |
| INLINECODE7 |
Yes | API key from Jellyfin Dashboard → Advanced → API Keys |
|
JF_USER | No | Username — used to resolve user ID for user-specific endpoints |
|
JF_USER_ID | No | User ID directly — avoids needing to call
/Users |
|
JF_PASS | No | Password — only if authenticating by user session |
TV Control (optional — choose one backend)
| Variable | Backend | Description |
|---|
| INLINECODE12 | All | Force backend: homeassistant, webos, androidtv, or INLINECODE16 |
| INLINECODE17 |
HA | Force platform:
webos or
androidtv (auto-detected from entity) |
|
HA_URL | HA | Home Assistant URL, e.g.
http://192.168.1.138:8123 |
|
HA_TOKEN | HA | HA long-lived access token (Profile → Long-Lived Access Tokens) |
|
HA_TV_ENTITY | HA | Entity ID of your TV, e.g.
media_player.lg_webos_tv_oled48c34la |
|
TV_IP | WebOS | LG TV IP address for direct WebOS SSAP connection |
|
TV_CLIENT_KEY | WebOS | Pairing key (printed on first connection — save it!) |
|
ADB_DEVICE | AndroidTV | TV address for ADB, e.g.
192.168.1.100:5555 |
|
TV_MAC | All | TV MAC address for Wake-on-LAN (needed to turn on TV) |
|
TV_JELLYFIN_APP | All | Override Jellyfin app ID (auto:
org.jellyfin.webos /
org.jellyfin.androidtv) |
|
TV_BOOT_DELAY | All | Seconds to wait after TV wake (default: 10) |
|
TV_APP_DELAY | All | Seconds to wait after launching Jellyfin (default: 8) |
Auto-detection: If TV_BACKEND is auto (default):
- 1.
HA_URL + HA_TOKEN + HA_TV_ENTITY set → Home Assistant backend - INLINECODE40 set → direct ADB (Android TV)
- INLINECODE41 set → direct WebOS (LG)
- Nothing set → TV commands disabled, Jellyfin-only mode
Usage
🎯 One-Command Play (the magic)
Turn on TV → launch Jellyfin → find next episode → play it. All in one command:
CODEBLOCK4
The skill validates the content exists BEFORE turning on the TV (fail fast).
Resume / Play Smart
If TV and Jellyfin are already running:
CODEBLOCK5
TV Control
CODEBLOCK6
Remote Control
CODEBLOCK7
Search Content
CODEBLOCK8
Library Stats & Scan
CODEBLOCK9
User History (requires admin API key)
CODEBLOCK10
Choosing a TV Backend
| Feature | Home Assistant | Direct WebOS | Direct ADB (Android TV) | No Backend |
|---|
| TV brands | Any (via HA) | LG only | Android TV, Fire TV, CCwGTV | — |
| Turn on (WoL) |
✅ | ✅ | ✅ (WoL or ADB wakeup) | — |
| Turn off | ✅ | ✅ | ✅ | — |
| Launch apps | ✅ | ✅ | ✅ | — |
| List apps | ✅ (via HA logs) | ✅ (direct output) | ✅ (direct output) | — |
| Extra dependency | None |
npm install ws |
apt install adb | None |
| Setup complexity | Medium (need HA) | Low (TV IP + MAC) | Low (enable ADB on TV) | None |
| Jellyfin playback | ✅ | ✅ | ✅ | ✅ |
Recommendation:
- - Already have Home Assistant? → Use HA backend (most versatile, any TV brand)
- LG WebOS TV, no HA? → Use direct WebOS backend
- Android TV / Fire TV / Chromecast with Google TV, no HA? → Use direct ADB backend
- No smart TV control needed? → Skip TV config,
resume works if Jellyfin app is already open
Security Notes
- - API keys only in
openclaw.json env — never in workspace files, .env files, or markdown docs. - HA tokens are long-lived and powerful. Create a dedicated HA user with limited permissions if possible.
- TVCLIENTKEY (WebOS) is sensitive — it allows full control of your TV. Treat it like a password.
- ADB access grants full control of your Android TV. Ensure your network is secured — anyone on the same network could connect via ADB if debugging is enabled.
- Admin operations (
history, scan) require an admin-level Jellyfin API key and will fail gracefully with 403 if permissions are insufficient.
Architecture
- -
lib/jellyfin.js — Jellyfin REST API (auth, search, sessions, playback control) - INLINECODE50 — TV control abstraction (HA backend, WebOS backend, Wake-on-LAN)
- INLINECODE51 — User-friendly CLI with all commands
Workflow: Agent says "Play Star Trek on TV"
CODEBLOCK11
Jellyfin 控制
通过命令行控制 Jellyfin 播放和电视电源的强大技能。
功能特性
- - 🎯 一键播放: tv play 绝命毒师 — 打开电视、启动 Jellyfin、查找下一集并开始播放。
- 智能续播: 自动查找剧集的下一个未播放剧集。
- 续播位置: 精确从上次停止位置继续播放电影/剧集(LG WebOS/Tizen 使用 Seek 回退方案)。
- 设备发现: 自动检测可控会话(电视、手机、网页端)。
- 远程控制: 完整的播放控制(播放、暂停、停止、下一集、上一集、音量、静音)。
- 电视电源与应用: 开关电视、启动应用 — 支持或不支持 Home Assistant 均可使用。
- 两种电视后端: Home Assistant 集成或直接 WebOS(LG 电视,无需 HA)。
- Android TV 支持: 适用于 Chromecast w/ Google TV、Nvidia Shield、Fire TV、Mi Box 的直接 ADB 后端 — 无需 HA。
- 三种连接模式: Home Assistant(任意电视)、直接 WebOS(LG)、直接 ADB(Android TV/Fire TV)。
快速开始
最小化配置(仅 Jellyfin,无电视控制)
json
{
skills: {
entries: {
jellyfin-control: {
env: {
JFURL: http://YOURIP:8096,
JFAPIKEY: your-api-key-here,
JF_USER: your-username
}
}
}
}
}
使用 Home Assistant(推荐用于电视控制)
json
{
skills: {
entries: {
jellyfin-control: {
env: {
JF_URL: http://192.168.1.50:8096,
JFAPIKEY: your-jellyfin-api-key,
JF_USER: victor,
HA_URL: http://192.168.1.138:8123,
HA_TOKEN: your-ha-long-lived-token,
HATVENTITY: mediaplayer.lgwebostvoled48c34la,
TV_MAC: AA:BB:CC:DD:EE:FF
}
}
}
}
}
直接 WebOS(LG 电视,无需 Home Assistant)
json
{
skills: {
entries: {
jellyfin-control: {
env: {
JF_URL: http://192.168.1.50:8096,
JFAPIKEY: your-jellyfin-api-key,
JF_USER: victor,
TV_IP: 192.168.1.100,
TV_MAC: AA:BB:CC:DD:EE:FF
}
}
}
}
}
首次使用直接 WebOS: 电视会显示配对提示。接受配对并将技能打印的 TVCLIENTKEY 保存下来 — 添加到环境变量中可跳过下次的配对提示。
直接 ADB(Android TV / Fire TV / Chromecast with Google TV,无需 HA)
json
{
skills: {
entries: {
jellyfin-control: {
env: {
JF_URL: http://192.168.1.50:8096,
JFAPIKEY: your-jellyfin-api-key,
JF_USER: victor,
ADB_DEVICE: 192.168.1.100:5555,
TV_MAC: AA:BB:CC:DD:EE:FF
}
}
}
}
}
首次使用 ADB: 在电视上启用开发者选项(设置 → 关于 → 连续点击版本号 7 次),然后启用网络/USB 调试。首次连接时电视会显示允许调试?提示 — 接受即可。需要在 OpenClaw 主机上安装 adb(sudo apt install adb)。
环境变量
Jellyfin(必需)
| 变量 | 必需 | 描述 |
|---|
| JFURL | 是 | Jellyfin 服务器基础 URL,例如 http://192.168.1.50:8096 |
| JFAPI_KEY |
是 | 来自 Jellyfin 仪表盘 → 高级 → API 密钥的 API 密钥 |
| JF_USER | 否 | 用户名 — 用于解析用户特定端点的用户 ID |
| JF
USERID | 否 | 直接提供用户 ID — 避免调用 /Users 端点 |
| JF_PASS | 否 | 密码 — 仅当通过用户会话进行身份验证时使用 |
电视控制(可选 — 选择一个后端)
| 变量 | 后端 | 描述 |
|---|
| TVBACKEND | 全部 | 强制指定后端:homeassistant、webos、androidtv 或 auto |
| TVPLATFORM |
HA | 强制指定平台:webos 或 androidtv(从实体自动检测) |
| HA_URL | HA | Home Assistant URL,例如 http://192.168.1.138:8123 |
| HA_TOKEN | HA | HA 长期访问令牌(个人资料 → 长期访问令牌) |
| HA
TVENTITY | HA | 电视的实体 ID,例如 media
player.lgwebos
tvoled48c34la |
| TV_IP | WebOS | 用于直接 WebOS SSAP 连接的 LG 电视 IP 地址 |
| TV
CLIENTKEY | WebOS | 配对密钥(首次连接时打印 — 请保存!) |
| ADB_DEVICE | AndroidTV | 用于 ADB 的电视地址,例如 192.168.1.100:5555 |
| TV_MAC | 全部 | 用于网络唤醒的电视 MAC 地址(打开电视必需) |
| TV
JELLYFINAPP | 全部 | 覆盖 Jellyfin 应用 ID(自动:org.jellyfin.webos / org.jellyfin.androidtv) |
| TV
BOOTDELAY | 全部 | 电视唤醒后等待的秒数(默认:10) |
| TV
APPDELAY | 全部 | 启动 Jellyfin 后等待的秒数(默认:8) |
自动检测: 如果 TV_BACKEND 设置为 auto(默认值):
- 1. 设置了 HAURL + HATOKEN + HATVENTITY → Home Assistant 后端
- 设置了 ADBDEVICE → 直接 ADB(Android TV)
- 设置了 TVIP → 直接 WebOS(LG)
- 未设置任何内容 → 禁用电视命令,仅 Jellyfin 模式
使用方法
🎯 一键播放(魔法功能)
打开电视 → 启动 Jellyfin → 查找下一集 → 开始播放。一条命令完成所有操作:
bash
node skills/jellyfin-control/cli.js tv play 绝命毒师
node skills/jellyfin-control/cli.js tv play 黑客帝国
该技能会在打开电视之前验证内容是否存在(快速失败)。
智能续播 / 播放
如果电视和 Jellyfin 已在运行:
bash
node skills/jellyfin-control/cli.js resume 绝命毒师
node skills/jellyfin-control/cli.js resume 黑客帝国 --device Chromecast
电视控制
bash
node skills/jellyfin-control/cli.js tv on # 打开电视(网络唤醒)
node skills/jellyfin-control/cli.js tv off # 关闭电视
node skills/jellyfin-control/cli.js tv launch # 启动 Jellyfin 应用
node skills/jellyfin-control/cli.js tv launch com.webos.app.hdmi1 # 启动特定应用
node skills/jellyfin-control/cli.js tv apps # 列出已安装的应用
远程控制
bash
node skills/jellyfin-control/cli.js control pause
node skills/jellyfin-control/cli.js control play
node skills/jellyfin-control/cli.js control next
node skills/jellyfin-control/cli.js control vol 50
搜索内容
bash
node skills/jellyfin-control/cli.js search 星球大战