Skip to content

Conversation

@donburch888
Copy link
Contributor

The C++ function names for the deep_sleep actions are not immediately obvious.

Description:

Related issue (if applicable): fixes

Pull request in esphome with YAML changes (if applicable):

  • esphome/esphome#

Checklist:

  • I am merging into next because this is new documentation that has a matching pull-request in esphome as linked above.
    or

  • I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • Link added in /components/index.rst when creating new documents for new components or cookbook.

New Component Images

If you are adding a new component to ESPHome, you can automatically generate a standardized black and white component name image for the documentation.

To generate a component image:

  1. Comment on this pull request with the following command, replacing COMPONENT_NAME with your component name in UPPER_CASE format with underscores (e.g., BME280, SHT3X, DALLAS_TEMP):

    @esphomebot generate image COMPONENT_NAME
    
  2. The ESPHome bot will respond with a downloadable ZIP file containing the SVG image.

  3. Extract the SVG file and place it in the images/ folder of this repository.

  4. Use the image in your component's index table entry in /components/index.rst.

Example: For a component called "DHT22 Temperature Sensor", use:

@esphomebot generate image DHT22

The C++ function names for the deep_sleep actions are not immediately obvious.
@esphome esphome bot added the current label Oct 22, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

Added lambda usage examples to the deep_sleep documentation that call methods on the deep_sleep_1 component for the deep_sleep.enter, deep_sleep.prevent, and deep_sleep.allow actions.

Changes

Cohort / File(s) Change Summary
Documentation Examples
content/components/deep_sleep.md
Inserted lambda snippets invoking id(deep_sleep_1).begin(true); for deep_sleep.enter, id(deep_sleep_1).prevent_deep_sleep(); for deep_sleep.prevent, and id(deep_sleep_1).allow_deep_sleep(); for deep_sleep.allow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Add lambda examples for deep sleep actions" clearly and directly summarizes the main change in the changeset. The raw summary confirms the PR adds lambda usage examples for three deep_sleep actions (enter, prevent, and allow) to the documentation. The title is concise, specific, and avoids vague language or noise, making it easy for teammates scanning the history to understand the primary purpose of the change.
Description Check ✅ Passed The pull request description is related to the changeset, explaining that the motivation for adding the lambda examples is to clarify the C++ function names for deep_sleep actions, which are "not immediately obvious." While the description is minimal and includes placeholder fields for a related issue and esphome PR reference, it provides meaningful context for why the change was made and is clearly relevant to the lambda examples being added to the documentation.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 20a6022 and 78721c6.

📒 Files selected for processing (1)
  • content/components/deep_sleep.md (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • content/components/deep_sleep.md

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.

Copy link
Contributor

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6211537 and 708d2b2.

📒 Files selected for processing (1)
  • content/components/deep_sleep.md (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

  • Do not generate or add any sequence diagrams

Files:

  • content/components/deep_sleep.md
🔇 Additional comments (1)
content/components/deep_sleep.md (1)

151-155: Lambda examples look good—verify C++ method names across all three actions.

The lambda examples for deep_sleep.enter, deep_sleep.prevent, and deep_sleep.allow are a helpful addition for users calling these directly in lambdas. However, I cannot verify that begin(true), prevent_deep_sleep(), and enable() are the correct C++ method names without access to the esphome codebase.

Please confirm the C++ method names are correct by searching the esphome repository or testing locally. You may also want to verify these names are part of the public API and stable across supported versions.

@netlify
Copy link

netlify bot commented Oct 22, 2025

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit 78721c6
🔍 Latest deploy log https://app.netlify.com/projects/esphome/deploys/68f985ca573093000800a090
😎 Deploy Preview https://deploy-preview-5515--esphome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@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: 0

♻️ Duplicate comments (1)
content/components/deep_sleep.md (1)

221-223: Verify indentation consistency for the lambda block.

A previous review flagged that the - lambda: |- line on line 223 (or line 222 in the current state) uses inconsistent indentation compared to the enter and prevent examples. The current display shows 2-space indentation, which would be consistent with lines 153 and 176, but please verify the actual character count is correct. If this is still using 4 spaces, apply the indentation fix from the previous review.

🧹 Nitpick comments (1)
content/components/deep_sleep.md (1)

220-221: Add blank line for consistent formatting with other action examples.

The allow section is missing a blank line between the action example and the # in a lambda comment, whereas both the enter and prevent sections have this blank line. Add a blank line at line 220 to maintain visual consistency.

    - deep_sleep.allow: deep_sleep_1

# in a lambda
  - lambda: |-
      id(deep_sleep_1).enable();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 708d2b2 and 30747b6.

📒 Files selected for processing (1)
  • content/components/deep_sleep.md (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

  • Do not generate or add any sequence diagrams

Files:

  • content/components/deep_sleep.md
🔇 Additional comments (1)
content/components/deep_sleep.md (1)

152-154: Lambda examples are well-targeted and address the PR objective.

The additions successfully provide lambda equivalents for the three deep_sleep actions with appropriate C++ method calls (begin(true), prevent_deep_sleep(), enable()). These examples clarify the non-obvious function names as intended by the PR.

Also applies to: 176-177, 222-223

Added example of enabling deep sleep in a lambda function.
CodeChimp gave inconsistent results (enable and disable vs prevent and allow)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant