- Replace single api_token with api_tokens dict (label: token pairs) - Add context-aware logging to track which client made each request - Implement token label lookup with secure comparison - Add logging middleware to inject token labels into request context - Update logging format to display [label] in all log messages - Fix WebSocket authentication to use new multi-token system - Update CLI --show-token to display all tokens with labels - Update config generation to use api_tokens format - Update README with multi-token documentation - Update config.example.yaml with multiple token examples Benefits: - Easy identification of clients in logs (Home Assistant, mobile, web UI, etc.) - Per-client token management and revocation - Better security and auditability Example log output: 2026-02-06 03:36:20,806 - [home_assistant] - WebSocket client connected Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
111 lines
2.4 KiB
YAML
111 lines
2.4 KiB
YAML
# Media Server Configuration
|
|
# Copy this file to config.yaml and customize as needed.
|
|
# A secure token will be auto-generated on first run if not specified.
|
|
|
|
# API Tokens - Multiple tokens with friendly labels
|
|
# This allows you to identify which client is making requests in the logs
|
|
api_tokens:
|
|
home_assistant: "your-home-assistant-token-here"
|
|
mobile: "your-mobile-app-token-here"
|
|
web_ui: "your-web-ui-token-here"
|
|
|
|
# Server settings
|
|
host: "0.0.0.0"
|
|
port: 8765
|
|
|
|
# Custom scripts
|
|
scripts:
|
|
lock_screen:
|
|
command: "rundll32.exe user32.dll,LockWorkStation"
|
|
label: "Lock Screen"
|
|
description: "Lock the workstation"
|
|
timeout: 5
|
|
shell: true
|
|
|
|
hibernate:
|
|
command: "shutdown /h"
|
|
label: "Hibernate"
|
|
description: "Hibernate the PC"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
sleep:
|
|
command: "rundll32.exe powrprof.dll,SetSuspendState 0,1,0"
|
|
label: "Sleep"
|
|
description: "Put PC to sleep"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
shutdown:
|
|
command: "shutdown /s /t 0"
|
|
label: "Shutdown"
|
|
description: "Shutdown the PC immediately"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
restart:
|
|
command: "shutdown /r /t 0"
|
|
label: "Restart"
|
|
description: "Restart the PC immediately"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
# Callback scripts (executed after media actions)
|
|
# All callbacks are optional - if not defined, the action runs without callback
|
|
callbacks:
|
|
# Media control callbacks (run after successful action)
|
|
on_play:
|
|
command: "echo Play triggered"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_pause:
|
|
command: "echo Pause triggered"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_stop:
|
|
command: "echo Stop triggered"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_next:
|
|
command: "echo Next track"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_previous:
|
|
command: "echo Previous track"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_volume:
|
|
command: "echo Volume changed"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_mute:
|
|
command: "echo Mute toggled"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_seek:
|
|
command: "echo Seek triggered"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
# Turn on/off/toggle (callback-only actions, no default behavior)
|
|
on_turn_on:
|
|
command: "echo Turn on callback"
|
|
timeout: 10
|
|
shell: true
|
|
|
|
on_turn_off:
|
|
command: "rundll32.exe user32.dll,LockWorkStation"
|
|
timeout: 5
|
|
shell: true
|
|
|
|
on_toggle:
|
|
command: "echo Toggle callback"
|
|
timeout: 10
|
|
shell: true |