diff --git a/spotify/DOCS.md b/spotify/DOCS.md index a363e63..2f08e44 100644 --- a/spotify/DOCS.md +++ b/spotify/DOCS.md @@ -35,6 +35,7 @@ Example add-on configuration: log_level: info name: HomeAssistant bitrate: 320 +initial-volume: 50 username: frenck@example.com password: MySpotifyPassword ``` @@ -74,6 +75,19 @@ 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. The behavior depends on the volume backend in use: + +- For softvol (default backend): Uses the specified value, defaulting to 50% +- For alsa mixer: Uses the specified value, falling back to the current system volume if not set + +To determine which backend is in use, check the addon logs for "Using softvol" or +"Using alsa mixer" messages during startup. + +initial-volume: 50 # Optional, defaults to 50 for softvol + ### Option: `username` **IMPORTANT**: _This requires a Spotify Premium account!_ diff --git a/spotify/config.yaml b/spotify/config.yaml index d0a4528..c4d2597 100644 --- a/spotify/config.yaml +++ b/spotify/config.yaml @@ -15,9 +15,11 @@ 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? + initial-volume: match(^([0-9]|[1-9][0-9]|100)$)? diff --git a/spotify/rootfs/etc/services.d/spotifyd/run b/spotify/rootfs/etc/services.d/spotifyd/run index e77f9a4..641d676 100755 --- a/spotify/rootfs/etc/services.d/spotifyd/run +++ b/spotify/rootfs/etc/services.d/spotifyd/run @@ -8,12 +8,22 @@ declare bitrate declare name declare password declare username +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}") diff --git a/spotify/translations/en.yaml b/spotify/translations/en.yaml index 94e5b72..3cf9b32 100644 --- a/spotify/translations/en.yaml +++ b/spotify/translations/en.yaml @@ -14,6 +14,12 @@ 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. + Default for softvol: 50. + For the alsa mixer: the current volume. username: name: Spotify username description: >- diff --git a/spotify/translations/hu.yaml b/spotify/translations/hu.yaml index 96406a0..7c33a40 100644 --- a/spotify/translations/hu.yaml +++ b/spotify/translations/hu.yaml @@ -14,6 +14,12 @@ 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. + A softvol alapértelmezett értéke: 50. + Az alsa keverő esetében: az aktuális térfogat. username: name: Spotify felhasználónév description: >- diff --git a/spotify/translations/it.yaml b/spotify/translations/it.yaml index 88e723d..9da19ab 100644 --- a/spotify/translations/it.yaml +++ b/spotify/translations/it.yaml @@ -14,6 +14,12 @@ 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. + Impostazione predefinita per softvol: 50. + Per il mixer alsa: il volume attuale. username: name: Spotify username description: >-