Stop the current song before starting a new one - #16
Merged
Merged
Conversation
Rtttl::play() returns early when a song is already running, so pressing a second button started the new LED effect while the old song kept playing. Each play_song_* script now stops playback before setting up the new song. Version 26.8.26.1 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Version: 26.8.26.1
What does this implement/fix?
Pressing a second song button while a song is playing started the new LED effect but left the old song playing. The new song never started.
Rtttl::play()returns early when a song is already running:The
light.turn_onactions inplay_song_*run before that and are not conditional, so the lights always switched and the audio never did.Each of the seven
play_song_*scripts now callsrtttl.stopfirst. On theoutputpathRtttl::stop()sets the level to 0 and moves straight toSTATE_STOPPEDin the same call, so the followingrtttl.play()sees a stopped component and starts normally.rtttl.stop()does not fireon_finished_playback(onlyfinish_()does), so interrupting a song does not run theall_lights_off+ShouldSleephandler and cannot put the ornament to sleep mid-song.play_buzzeris left alone. It has the same limitation, but it deliberately does not setsong_active, and making it interrupt a song would leave that flag stale and let the API action trigger a sleep. Worth a separate look.Types of changes
Checklist / Checklijst:
If user-visible functionality or configuration variables are added/modified:
esphome configpasses on both H-3.yaml and H-3D.yaml, and the merged config renders all sevenrtttl.stopactions. Not yet tested on hardware.🤖 Generated with Claude Code