Skip to content

Conversation

@bharvey88
Copy link
Contributor

@bharvey88 bharvey88 commented Nov 23, 2025

…component

Remove deep_sleep from external components and use the built in core component

Version:

What does this implement/fix?

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

  • New Features

    • Added a persistent test-mode toggle (defaults enabled) and an automated test sequence that can run at startup, on reset, or via multi-press/hold button actions.
    • Added a test cycle counter and brief RGB visual feedback during test runs.
    • Updated button interactions: long-press and multi-click flows to control test mode, prevent sleep, and reset counters.
  • Chores

    • Removed an unused external integration.

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

…component

Remove deep_sleep from external components and use the built in core component
@coderabbitai
Copy link

coderabbitai bot commented Nov 23, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces test orchestration in Integrations/ESPHome/Core.yaml: bumps substitutions.version, adds globals runTest and testCycleCount, replaces button handlers with on_multi_click sequences, adds testScript, integrates a wake-up/on-boot path that conditionally runs the script, and removes deep_sleep from external_components.

Changes

Cohort / File(s) Summary
Core configuration
Integrations/ESPHome/Core.yaml
Bumped substitutions.version 25.11.6.125.12.5.1; removed deep_sleep from external_components (kept max17048).
Globals added
Integrations/ESPHome/Core.yaml
Added globals: entries: runTest (bool, restore_value: yes, initial_value: "true") and testCycleCount (int, restore_value: no, initial_value: "0").
Button / input flows
Integrations/ESPHome/Core.yaml
Replaced reset_button on_press/on_release with on_multi_click sequences (10s hold, 3s hold+0.2s off, short press) that toggle runTest, reset testCycleCount, enable prevent_sleep/factory reset, or invoke testScript and status checks.
Wake-up / init flows
Integrations/ESPHome/Core.yaml
Added on_boot/wake-up path that reads runTest and conditionally invokes testScript; updated startup/wake logic to set/check runTest and testCycleCount.
Script added
Integrations/ESPHome/Core.yaml
Added script: testScript which, when runTest is true, sets runTest=false, resets testCycleCount to 0, briefly turns the RGB light green, then turns it off.
Formatting / minor edits
Integrations/ESPHome/Core.yaml
Minor YAML indentation/formatting adjustments to accommodate new globals, testScript, and on_multi_click blocks.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Button as Button/Input
  participant Boot as startup / on_wake
  participant Globals as Globals\n(runTest, testCycleCount)
  participant Script as testScript
  participant Light as RGB Light

  Button->>Boot: multi-click / hold event
  Boot->>Globals: read runTest
  alt runTest == true
    Boot->>Script: invoke testScript()
    Script->>Globals: set runTest = false
    Script->>Globals: set testCycleCount = 0
    Script->>Light: turn green ON
    Script->>Script: delay
    Script->>Light: turn OFF
    Script-->>Boot: return
  else runTest == false
    Boot->>Boot: continue normal startup/status flows
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Verify persistence and restore_value behavior for runTest.
  • Inspect all call sites that modify testCycleCount / runTest for race conditions or inconsistent ordering.
  • Confirm removal of deep_sleep has no remaining references and prevent_sleep flags are handled consistently.
  • Review on_multi_click timing/thresholds and ensure intended interactions (10s, 3s+0.2s, short press) behave on device.

Poem

🐰 I nudged a flag at morning light,
Green blinked once then tucked away,
Counters zeroed, the test took flight,
A gentle hop through YAML play—
I curled up warm and dreamed of day.

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 title accurately describes the main change: removing deep_sleep from external components and using the built-in core component, which aligns with the changeset's primary modification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4000519 and 7e575b9.

📒 Files selected for processing (1)
  • Integrations/ESPHome/Core.yaml (5 hunks)

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

@github-actions github-actions bot added the bugfix Something isn't working label Dec 4, 2025
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Integrations/ESPHome/Core.yaml (1)

300-301: Remove or uncomment the commented test initialization code.

Lines 300–301 contain commented code that appears related to the new test logic:

// id(testCycleCount) = 0;
// id(runTest) = true;

This logic is now implemented a few lines below (lines 315–317). Either remove these comments entirely or, if they represent alternative logic, document why they are needed separately.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d5d02a and be491b6.

📒 Files selected for processing (1)
  • Integrations/ESPHome/Core.yaml (5 hunks)
⏰ 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/BTN-1_Minimal.yaml / ESPHome beta
  • GitHub Check: Building Integrations/ESPHome/BTN-1_Minimal.yaml / ESPHome dev
  • GitHub Check: Building Integrations/ESPHome/BTN-1_Minimal.yaml / ESPHome stable
  • GitHub Check: Building Integrations/ESPHome/BTN-1.yaml / ESPHome beta
  • GitHub Check: Building Integrations/ESPHome/BTN-1.yaml / ESPHome dev
  • GitHub Check: Building Integrations/ESPHome/BTN-1.yaml / ESPHome stable
🔇 Additional comments (4)
Integrations/ESPHome/Core.yaml (4)

161-168: Clarify the intent of runTest persistence and testCycleCount usage.

Two new globals are introduced: runTest has restore_value: yes (persists across reboots with initial value "true"), meaning the device will execute the test script on every boot. testCycleCount is initialized to 0 but appears to be set but never incremented or read elsewhere in the script.

Is restore_value: yes for runTest intentional? If the device is meant to test automatically after every reboot, this is fine, but it should be documented. Additionally, clarify the purpose of testCycleCount—is it intended to track test iterations, and if so, should it be incremented somewhere (e.g., within testScript)?


74-80: Verify on_boot hook timing and interaction with other boot priorities.

A new on_boot hook at priority -10 is added to trigger testScript if runTest is true. This priority is very late in the boot sequence (after priority -900 wake detection logic at line 37). Confirm that executing the test script at this stage does not interfere with normal device startup or other higher-priority initialization tasks.

Review all on_boot priorities in the file to ensure -10 is the correct timing for test execution and does not conflict with sensor updates, API initialization, or other critical startup operations.


315-317: Verify reset button's new test script invocation.

The reset button's short-press behavior (< 3 seconds) now initializes test globals and calls testScript (lines 315–317). Ensure this change is intentional and tested, as it alters the button's existing behavior. Previously (based on comment at line 312), this was a "StatusCheck" action; now it doubles as a test trigger.

Confirm that this behavior is desired and document it. Also verify that calling statusCheck followed by testScript (both at line 313 and 317) doesn't cause redundant or conflicting operations.


141-143: No action needed—deep_sleep component migration is complete.

The removal of the external deep_sleep component from external_components is fully complete. All references throughout the codebase use the built-in deep_sleep: component (defined at lines 192–206 with id: deep_sleep_1), and no remaining references to the external GitHub component exist in any YAML files.

Comment on lines 703 to 723
- id: testScript
then:
if:
condition:
- lambda: "return id(runTest) == true;"
then:
- lambda: "id(runTest) = false;"
- lambda: "id(testCycleCount) = 0;"
- lambda: "id(runTest) = false;"
- light.turn_on:
id: rgb_light
red: 0%
green: 100%
blue: 0%
- delay: 5s
- light.turn_on:
id: rgb_light
red: 0%
green: 0%
blue: 0%
- light.turn_off:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix redundant state assignments and unused variable in testScript.

The testScript contains logic issues:

  1. Redundant assignment: runTest is set to false twice (lines 709 and 711).
  2. Unused variable: testCycleCount is set to 0 (line 710) but never incremented or checked within the script.
  3. Redundant condition check: The script checks runTest == true at line 707, but it's only invoked from callers that already verify runTest is true (lines 78, 317), making the condition unnecessary.

Apply this diff to clean up the logic:

  - id: testScript
    then:
      if: 
-       condition:
-         - lambda: "return id(runTest) == true;"
-       then:
-         - lambda: "id(runTest) = false;"
-         - lambda: "id(testCycleCount) = 0;"
-         - lambda: "id(runTest) = false;"
+       condition:
+         - lambda: "return id(runTest) == true;"
+       then:
+         - lambda: "id(runTest) = false;"
          - light.turn_on:
              id: rgb_light
              red: 0%
              green: 100%
              blue: 0%
          - delay: 5s
          - light.turn_on:
              id: rgb_light
              red: 0%
              green: 0%
              blue: 0%
          - light.turn_off:
              id: rgb_light

Additionally, document the purpose of testCycleCount. If it should track the number of test iterations, add logic to increment it; otherwise, remove it from the globals to avoid confusion.

📝 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: testScript
then:
if:
condition:
- lambda: "return id(runTest) == true;"
then:
- lambda: "id(runTest) = false;"
- lambda: "id(testCycleCount) = 0;"
- lambda: "id(runTest) = false;"
- light.turn_on:
id: rgb_light
red: 0%
green: 100%
blue: 0%
- delay: 5s
- light.turn_on:
id: rgb_light
red: 0%
green: 0%
blue: 0%
- light.turn_off:
- id: testScript
then:
if:
condition:
- lambda: "return id(runTest) == true;"
then:
- lambda: "id(runTest) = false;"
- light.turn_on:
id: rgb_light
red: 0%
green: 100%
blue: 0%
- delay: 5s
- light.turn_on:
id: rgb_light
red: 0%
green: 0%
blue: 0%
- light.turn_off:
id: rgb_light
🤖 Prompt for AI Agents
In Integrations/ESPHome/Core.yaml around lines 703 to 723, clean up testScript
by removing the redundant assignments and unnecessary condition: delete the
duplicate "id(runTest) = false;" (lines 709 and 711) and remove the surrounding
"if: condition: - lambda: 'return id(runTest) == true;'" block so the actions
run directly (or alternatively keep the callers' pre-checks and remove the local
check entirely). For testCycleCount (line 710) either document and implement
increment logic to track iterations (e.g., increment at each run) or remove it
from globals and this script if it is unused; ensure any remaining state changes
are singular (no duplicate state writes) and keep the light on/off sequence as
the only actions.

@Bunton33
Copy link
Contributor

Bunton33 commented Dec 5, 2025

Fixed. Thanks!

@Bunton33 Bunton33 closed this Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants