Skip to content

Conversation

@firstof9
Copy link

@firstof9 firstof9 commented Dec 17, 2025

Version:

What does this implement/fix?

Splits song scripts between the 2 firmware types to allow for brighter LEDs and louder buzzer audio.
Do not adjust LED brightness levels if the LEDs are already on.

Types of changes

  • Bugfix (fixed change that fixes an issue)
  • New feature (thanks!)
  • Breaking change (repair/feature that breaks existing functionality)
  • Dependency Update - Does not publish
  • Other - Does not publish
  • Website of github readme file update - Does not publish
  • Github workflows - Does not publish

Checklist / Checklijst:

  • The code change has been tested and works locally
  • The code change has not yet been tested

If user-visible functionality or configuration variables are added/modified:

  • Added/updated documentation for the web page

Summary by CodeRabbit

  • Refactor
    • Reorganized song playback automation with new conditional LED light control logic
    • Modified RGB and accent light behavior during music playback sequences
    • Updated brightness and visual effects application across devices
    • Restructured automation configuration for improved song-light synchronization

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

The pull request refactors ESPHome automation scripts across three configuration files: removing song and color-effect definitions from Core.yaml, replacing extended play_song_X scripts with explicit conditional implementations in H-2.yaml, and introducing new play_song_1 through play_song_x scripts in H-2D.yaml. Changes center on conditional light activation patterns before RTTTL playback.

Changes

Cohort / File(s) Summary
Core.yaml Cleanup
Integrations/ESPHome/Core.yaml
Removed five song scripts (play_song_1 through play_song_x) with their associated light orchestration, RTTTL playback, and delays. Removed six addressable_lambda color effects (RainbowWave, TwinklingWhite, RedGreen, BlueGold, Sandstorm, TwinklingBlues) from rgb_light and logo_light. Modified testScript end-state to turn RGB light green, wait, then turn off.
H-2.yaml Script Replacement
Integrations/ESPHome/H-2.yaml
Replaced extended play_song_1 through play_song_4 with explicit script definitions featuring conditional light-activation branches (checking rgb_light and logo_light state before applying effects and brightness). Added new generic play_song_x script with conditional light-on blocks and RTTTL playback. Restructured control flow to conditionally enable lights prior to playback.
H-2D.yaml Script Addition
Integrations/ESPHome/H-2D.yaml
Added five new automation scripts (play_song_1 through play_song_4 and play_song_x) following a consistent pattern: conditionally activate rgb_light and logo_light with brightness and effects, play RTTTL track, delay 30s, turn off lights, then trigger ShouldSleep.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Areas requiring attention:

  • Verify conditional logic branches in H-2.yaml (brightness and effect application paths) align with intended behavior for each song script
  • Confirm public entity signature changes in H-2.yaml (play_song_1 through play_song_4 transitioning from extended to explicit definitions) do not break dependencies
  • Validate H-2D.yaml script patterns are consistent and complete (conditional light states, timing, and ShouldSleep trigger)
  • Ensure Core.yaml removals do not orphan references in other configuration files

Possibly related PRs

Poem

🐰 Hop-hop, the songs now dance with light!
Conditional whiskers twitch just right—
Green glow fades to sleep's embrace,
Each tune now knows its proper place!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: splitting song scripts between two firmware types (Core.yaml vs H-2.yaml/H-2D.yaml), which is the core objective reflected in the summary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@firstof9 firstof9 marked this pull request as ready for review December 17, 2025 15:51
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

🧹 Nitpick comments (1)
Integrations/ESPHome/H-2D.yaml (1)

117-280: Consider extracting repeated conditional light activation logic.

All five play_song_* scripts repeat the same conditional pattern for turning on rgb_light and logo_light. While ESPHome YAML has limitations, you could potentially use a helper script with parameters (if supported by your ESPHome version) or accept the duplication for clarity.

This is a minor maintainability concern; the current implementation is functionally correct.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35c2249 and adae7c1.

📒 Files selected for processing (3)
  • Integrations/ESPHome/Core.yaml (0 hunks)
  • Integrations/ESPHome/H-2.yaml (4 hunks)
  • Integrations/ESPHome/H-2D.yaml (1 hunks)
💤 Files with no reviewable changes (1)
  • Integrations/ESPHome/Core.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Building Integrations/ESPHome/H-2.yaml / ESPHome stable / ESPHome stable
  • GitHub Check: Building Integrations/ESPHome/H-2D.yaml / ESPHome dev / ESPHome dev
  • GitHub Check: Building Integrations/ESPHome/H-2.yaml / ESPHome beta / ESPHome beta
  • GitHub Check: Building Integrations/ESPHome/H-2D.yaml / ESPHome stable / ESPHome stable
  • GitHub Check: Building Integrations/ESPHome/H-2.yaml / ESPHome dev / ESPHome dev
  • GitHub Check: Building Integrations/ESPHome/H-2D.yaml / ESPHome beta / ESPHome beta
🔇 Additional comments (4)
Integrations/ESPHome/H-2D.yaml (1)

117-148: Verify wifi handling is intentionally omitted for H-2D.

The H-2D scripts don't include wifi.disable/wifi.enable around rtttl.play, unlike the H-2.yaml counterparts. If this is intentional due to hardware differences, consider adding a brief comment explaining why. If omitted by mistake, the buzzer audio may not be as loud as intended (based on the PR objective).

Integrations/ESPHome/H-2.yaml (3)

127-138: Verify if play_song_x needs an API service.

API services are defined for play_song_1 through play_song_4, but not for play_song_x. If play_song_x is an internal/easter-egg script, this is fine. If it should be callable via Home Assistant, add a corresponding service.


279-282: Good use of wifi disable/enable around audio playback.

Disabling wifi during RTTTL playback helps ensure cleaner audio by reducing RF interference. This aligns well with the PR objective for louder buzzer audio.


253-286: LGTM - Well-structured conditional light activation.

The pattern of checking remote_values.is_on() before setting brightness ensures user-set brightness is preserved when lights are already on, while providing sensible defaults when waking from sleep. Good implementation.

Comment on lines +393 to +426
- id: play_song_x
then:
- if:
condition:
lambda: 'return !id(rgb_light).remote_values.is_on();'
then:
- light.turn_on:
id: rgb_light
brightness: 80%
effect: "Sandstorm"
else:
- light.turn_on:
id: rgb_light
effect: "Sandstorm"
- if:
condition:
lambda: 'return !id(logo_light).remote_values.is_on();'
then:
- light.turn_on:
id: logo_light
brightness: 60%
effect: "Sandstorm"
else:
- light.turn_on:
id: logo_light
effect: "Sandstorm"
- wifi.disable:
- rtttl.play:
rtttl: Sandstorm:d=16,o=6,b=85:e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e, 8e,e,a,e,e,e,e,8e,e,d,e,e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e,8e,e, a,e,e,e,e,8e,e,d,e,e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e,8e,e,a,e, e,e,e,8e,e,d,e
- wifi.enable:
- delay: 30s
- light.turn_off: rgb_light
- light.turn_off: logo_light
- script.execute: ShouldSleep
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Brightness inconsistency in play_song_x.

play_song_x uses 80% brightness for rgb_light (line 401), while play_song_1 through play_song_4 use 90%. If this is intentional, please disregard. Otherwise, apply this diff for consistency:

       - if:
           condition:
             lambda: 'return !id(rgb_light).remote_values.is_on();'
           then:
             - light.turn_on:
                 id: rgb_light
-                brightness: 80%
+                brightness: 90%
                 effect: "Sandstorm"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- id: play_song_x
then:
- if:
condition:
lambda: 'return !id(rgb_light).remote_values.is_on();'
then:
- light.turn_on:
id: rgb_light
brightness: 80%
effect: "Sandstorm"
else:
- light.turn_on:
id: rgb_light
effect: "Sandstorm"
- if:
condition:
lambda: 'return !id(logo_light).remote_values.is_on();'
then:
- light.turn_on:
id: logo_light
brightness: 60%
effect: "Sandstorm"
else:
- light.turn_on:
id: logo_light
effect: "Sandstorm"
- wifi.disable:
- rtttl.play:
rtttl: Sandstorm:d=16,o=6,b=85:e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e, 8e,e,a,e,e,e,e,8e,e,d,e,e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e,8e,e, a,e,e,e,e,8e,e,d,e,e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e,8e,e,a,e, e,e,e,8e,e,d,e
- wifi.enable:
- delay: 30s
- light.turn_off: rgb_light
- light.turn_off: logo_light
- script.execute: ShouldSleep
- id: play_song_x
then:
- if:
condition:
lambda: 'return !id(rgb_light).remote_values.is_on();'
then:
- light.turn_on:
id: rgb_light
brightness: 90%
effect: "Sandstorm"
else:
- light.turn_on:
id: rgb_light
effect: "Sandstorm"
- if:
condition:
lambda: 'return !id(logo_light).remote_values.is_on();'
then:
- light.turn_on:
id: logo_light
brightness: 60%
effect: "Sandstorm"
else:
- light.turn_on:
id: logo_light
effect: "Sandstorm"
- wifi.disable:
- rtttl.play:
rtttl: Sandstorm:d=16,o=6,b=85:e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e, 8e,e,a,e,e,e,e,8e,e,d,e,e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e,8e,e, a,e,e,e,e,8e,e,d,e,e,e,e,e,8e,e,e,a,a,a,a,g,g,g,d,e,e,e,e,8e,e,a,e, e,e,e,8e,e,d,e
- wifi.enable:
- delay: 30s
- light.turn_off: rgb_light
- light.turn_off: logo_light
- script.execute: ShouldSleep
🤖 Prompt for AI Agents
In Integrations/ESPHome/H-2.yaml around lines 393 to 426, the play_song_x
sequence sets rgb_light brightness to 80% while play_song_1 through play_song_4
use 90%; update the rgb_light brightness in the play_song_x then block from 80%
to 90% so it matches the other play_song handlers for consistent lighting
behavior.

@bharvey88 bharvey88 merged commit f33d7bb into ApolloAutomation:beta Dec 23, 2025
7 of 8 checks passed
@firstof9 firstof9 deleted the fix-1 branch December 24, 2025 13:56
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.

2 participants