Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add librespot initial-volume option #276

Merged
merged 19 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions spotify/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Example add-on configuration:
log_level: info
name: HomeAssistant
bitrate: 320
initial-volume: 50
username: frenck@example.com
password: MySpotifyPassword
autoplay: true
Expand Down Expand Up @@ -75,6 +76,13 @@ however, the add-on consumes more data.

Valid values: `96`, `160` (default) or `320`.

### Option: `initial-volume`

Initial volume in % from 0-100. This setting takes effect when the addon starts or
recovers from a crash.

initial-volume: 50 # Optional

### Option: `username`

**IMPORTANT**: _This requires a Spotify Premium account!_
Expand Down
2 changes: 2 additions & 0 deletions spotify/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ init: false
options:
name: Home Assistant
bitrate: 160
initial-volume: 50
schema:
log_level: list(trace|debug|info|notice|warning|error|fatal)?
name: str
bitrate: list(96|160|320)
username: str?
password: password?
autoplay: bool
initial-volume: match(^([0-9]|[1-9][0-9]|100)$)?
10 changes: 10 additions & 0 deletions spotify/rootfs/etc/services.d/spotifyd/run
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ declare name
declare password
declare username
declare autoplay
declare initial-volume

bashio::log.info 'Starting the Spotify daemon...'

# Bitrate
options+=(--bitrate $(bashio::config 'bitrate'))

# Initial Volume
initial_volume=$(bashio::config 'initial-volume')
if ! [[ "$initial_volume" =~ ^[0-9]+$ ]] || [ "$initial_volume" -lt 0 ] || [ "$initial_volume" -gt 100 ]; then
bashio::log.warning "Invalid initial-volume value: $initial_volume. Using default."
initial_volume=50
fi
options+=(--initial-volume "$initial_volume")


# Device name
name=$(bashio::config 'name')
options+=(--name "${name}")
Expand Down
4 changes: 4 additions & 0 deletions spotify/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ configuration:
description: >-
The bitrate Spotify should use. The higher, the better the sound quality,
however, the add-on consumes more data.
initial-volume:
name: Initial Volume
description: >-
Initial volume in % from 0-100.
username:
name: Spotify username
description: >-
Expand Down
4 changes: 4 additions & 0 deletions spotify/translations/hu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ configuration:
description: >-
A Spotify által használt bitráta beállítása. Minél magasabb, annál jobb
minőségű, viszont ez nagyobb adatforgalommal jár.
initial-volume:
name: Kezdeti térfogat
description: >-
Kezdeti térfogat %-ban 0-100 között.
username:
name: Spotify felhasználónév
description: >-
Expand Down
4 changes: 4 additions & 0 deletions spotify/translations/it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ configuration:
description: >-
Il bitrate che Spotify dovrebbe usare. Piú é alto, migliore é la qualitá sonora,
tuttavia, l'add-on consumerá piú banda.
initial-volume:
name: Volume Iniziale
description: >-
Volume iniziale in % da 0 a 100.
username:
name: Spotify username
description: >-
Expand Down
Loading