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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

spoetnik
Copy link

@spoetnik spoetnik commented Dec 6, 2024

Proposed Changes

Add the librespot initial-volume option. On startup, or after a crash, the volume of spotify goed back to default which is not a convenient level. This configurable option lets the user have influence on this level after a startup of this addon

Related Issues

Helps to minimize the impact of this one #274

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new configuration option, initial-volume, allowing users to set the starting volume level (0-100%) for the Spotify Connect add-on.
    • Updated documentation to reflect the new initial-volume option and its usage.
  • Translations

    • Added initial-volume configuration entry in English, Hungarian, and Italian translations, including name and description details for user clarity.

Copy link

coderabbitai bot commented Dec 6, 2024

Walkthrough

The changes introduce a new configuration option, initial-volume, across multiple files related to the Home Assistant Spotify Connect add-on. This option allows users to set the initial volume level as a percentage from 0 to 100, with a default of 50 for softvol and the current volume for the ALSA mixer. Updates were made to the documentation, configuration schema, service script, and translation files to accommodate this new feature.

Changes

File Change Summary
spotify/DOCS.md Added initial-volume configuration option description and example.
spotify/config.yaml Introduced initial-volume: 50 in options and updated schema to include initial-volume: int?.
spotify/rootfs/etc/services.d/spotifyd/run Added variable declare initial-volume and included validation for it in the Spotify daemon script.
spotify/translations/en.yaml Added initial-volume entry with name: Initial Volume and description in English.
spotify/translations/hu.yaml Added initial-volume entry with name: Kezdeti térfogat and description in Hungarian.
spotify/translations/it.yaml Added initial-volume entry with name: Volume Iniziale and description in Italian.

Poem

In the land of tunes and cheer,
A volume setting now draws near.
From zero to a hundred bright,
Control your sound, make it just right!
With every note that hops and plays,
Enjoy your music in new ways! 🎶🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ebd406a and 62182ef.

📒 Files selected for processing (5)
  • spotify/DOCS.md (2 hunks)
  • spotify/rootfs/etc/services.d/spotifyd/run (1 hunks)
  • spotify/translations/en.yaml (1 hunks)
  • spotify/translations/hu.yaml (1 hunks)
  • spotify/translations/it.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • spotify/rootfs/etc/services.d/spotifyd/run
  • spotify/translations/en.yaml
  • spotify/DOCS.md
  • spotify/translations/it.yaml
  • spotify/translations/hu.yaml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
spotify/translations/en.yaml (1)

20-22: Remove trailing spaces from description

The YAML linter detected trailing spaces at the end of lines.

Apply this diff:

-      Initial volume in % from 0-100. 
-      Default for softvol: 50. 
-      For the alsa mixer: the current volume.
+      Initial volume in % from 0-100.
+      Default for softvol: 50.
+      For the alsa mixer: the current volume.
🧰 Tools
🪛 yamllint (1.35.1)

[error] 20-20: trailing spaces

(trailing-spaces)


[error] 21-21: trailing spaces

(trailing-spaces)

spotify/translations/it.yaml (1)

18-18: Translate "Initial Volume" to Italian

For consistency with other translations in the file, the name should be in Italian.

Apply this diff:

-    name: Initial Volume
+    name: Volume Iniziale
spotify/translations/hu.yaml (1)

18-18: Translate the name field to Hungarian

The name field "Initial Volume" should be translated to Hungarian to maintain consistency with other configuration options in the file.

spotify/rootfs/etc/services.d/spotifyd/run (1)

18-19: Add validation for initial-volume configuration value

The script should validate that the initial-volume value is within the valid range (0-100) before passing it to librespot.

Consider adding validation like this:

 # 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 $(bashio::config 'initial-volume'))
+options+=(--initial-volume "$initial_volume")
spotify/DOCS.md (3)

78-81: Enhance documentation for initial-volume option

The documentation could be more detailed about:

  1. The behavior differences between softvol and alsa mixer
  2. When this setting takes effect (startup, crash recovery)
  3. How to determine which volume backend is in use

Consider expanding the documentation like this:

 ### Option: `initial-volume`
 
-Initial volume in % from 0-100. Default for softvol: 50. For the alsa mixer: the current 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.

38-38: Consider documenting initial-volume as optional in example

Since this setting has reasonable defaults, consider making it clear in the example that it's optional.

-initial-volume: 50
+initial-volume: 50  # Optional, defaults to 50 for softvol

Translation needed for "Initial Volume" in Hungarian and Italian language files

  • spotify/translations/hu.yaml: "Initial Volume" needs to be translated to Hungarian
  • spotify/translations/it.yaml: "Initial Volume" needs to be translated to Italian

The description fields are properly translated in both files, but the name field remains in English.

🔗 Analysis chain

Line range hint 17-22: Verify translations in all language files

Let's ensure this new configuration option is properly translated in all supported language files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if initial-volume is present in all translation files
# and if the name field is properly translated (not in English)

echo "Checking translation files for initial-volume..."
for f in $(fd -e yaml . spotify/translations); do
  echo "=== $f ==="
  # Check if initial-volume exists
  grep -A 3 "initial-volume:" "$f" || echo "Missing initial-volume section"
  # Check if name is in English
  grep -A 1 "initial-volume:" "$f" | grep "name: Initial Volume" && echo "WARNING: Name field is in English"
done

Length of output: 1584

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a1f0d43 and de806ef.

📒 Files selected for processing (6)
  • spotify/DOCS.md (2 hunks)
  • spotify/config.yaml (1 hunks)
  • spotify/rootfs/etc/services.d/spotifyd/run (1 hunks)
  • spotify/translations/en.yaml (1 hunks)
  • spotify/translations/hu.yaml (1 hunks)
  • spotify/translations/it.yaml (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
spotify/translations/en.yaml

[error] 20-20: trailing spaces

(trailing-spaces)


[error] 21-21: trailing spaces

(trailing-spaces)

🔇 Additional comments (1)
spotify/translations/it.yaml (1)

17-22: Verify translations in all language files

The initial-volume configuration has been added to English and Italian translations. Let's verify if other language files need to be updated as well.

✅ Verification successful

All translation files include the initial-volume configuration

The verification shows that all YAML files in the spotify/translations directory contain the initial-volume configuration, as the grep search returned no files missing this entry. This indicates proper synchronization across all language files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all translation files and check for initial-volume entry
echo "Translation files without initial-volume configuration:"
fd -e yaml -e yml . spotify/translations -x grep -L "initial-volume" {}

Length of output: 194

spotify/config.yaml Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant