Skip to content

Conversation

@edwardtfn
Copy link
Contributor

Description:

This is a copy of #5214, but in the new format.
That one should have been merged when esphome/esphome#10118 was merged, but for some reason it was missed.

Related issue (if applicable): N/A

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

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

This is a copy of esphome#5214, but in the new format.
That one should have been merged when esphome/esphome#10118 was merged, but for some reason it was missed.
esphome[bot]
esphome bot previously requested changes Oct 21, 2025
Copy link

@esphome esphome bot left a comment

Choose a reason for hiding this comment

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

As this is a feature matched with a PR in https://github.com/esphome/esphome, please target your PR to the next branch and rebase.

@esphome esphome bot marked this pull request as draft October 21, 2025 04:57
@esphome
Copy link

esphome bot commented Oct 21, 2025

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@edwardtfn edwardtfn marked this pull request as ready for review October 21, 2025 04:57
@esphome esphome bot dismissed their stale review October 21, 2025 04:58

Stale

@netlify
Copy link

netlify bot commented Oct 21, 2025

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit 5d5ea32
🔍 Latest deploy log https://app.netlify.com/projects/esphome/deploys/68f712a31c2c320008bb16dc
😎 Deploy Preview https://deploy-preview-5506--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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

Documentation for the switch component is updated to introduce and describe the switch.control API, a unified boolean-based control method. Examples and guidance sections are updated to include control() alongside existing turn_on, turn_off, and toggle methods.

Changes

Cohort / File(s) Summary
Switch component documentation
content/components/switch/_index.md
Adds switch.control API documentation with configuration parameters (id, state), usage examples, and updates existing sections (publish_state example, lambda calls) to reference the new control method as an alternative to traditional on/off/toggle operations

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "[switch] Add control() method to API" is concise, clear, and directly related to the changeset. It accurately summarizes the main objective of the pull request, which is to add documentation for a new control() method in the switch component API. The title uses appropriate formatting with the component name in brackets and a descriptive action phrase, making it easy for teammates reviewing the commit history to understand the primary change.
Description Check ✅ Passed The description is related to the changeset and provides relevant context about the pull request. It explains that this documentation update corresponds to a feature that was already merged in the main esphome repository (esphome/esphome#10118) but was missed in the documentation repository, and references the original PR #5214. While the description could include more details about what the control() method does, the check is lenient and only requires that the description be related in some way to the changeset, which it clearly is.
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 6ed85f2 and 5d5ea32.

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

⚙️ CodeRabbit configuration file

  • Do not generate or add any sequence diagrams

Files:

  • content/components/switch/_index.md
🔇 Additional comments (3)
content/components/switch/_index.md (3)

118-143: Well-structured addition of switch.control action documentation.

The new section is clearly written, follows the established pattern of other action sections (e.g., turn_on, turn_off), and includes both simple and templatable examples. Configuration variables are properly documented with required/optional status and types. The section integrates seamlessly with the existing documentation.


177-185: Correctly updates the note to include control() method.

The update to line 185 appropriately adds control() to the list of methods that manipulate actual switch state. The change maintains grammatical correctness and clarity within the NOTE block.


209-217: Clear and practical lambda method documentation for control().

The new documentation for the control() lambda method is well-integrated into the existing lambda calls section. The description clearly conveys the method's purpose, and the three examples progress logically from simple boolean calls to conditional usage, effectively demonstrating the method's flexibility. The formatting is consistent with surrounding lambda method documentation.


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.

@nagyrobi nagyrobi merged commit 6211537 into esphome:current Oct 21, 2025
8 checks passed
zopieux pushed a commit to zopieux/esphome-docs that referenced this pull request Oct 21, 2025
This is a copy of esphome#5214, but in the new format.
That one should have been merged when esphome/esphome#10118 was merged, but for some reason it was missed.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants