Skip to content

Conversation

@mik-laj
Copy link

@mik-laj mik-laj commented Oct 16, 2025

Added alternative usage example for binary sensor configuration.

Honestly, I was surprised that Binary Template supports the condition parameter, as it's a fairly new feature (~1 year ago, PR: PR-7561 ). So I'm adding it here because I think it could be an interesting replacement in many cases, as the condition feature is a bit more advanced, but still allows for all configuration to be in YAML.

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

Added alternative usage example for binary sensor configuration.
esphome[bot]
esphome bot previously requested changes Oct 16, 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 16, 2025 17:32
@esphome
Copy link

esphome bot commented Oct 16, 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an alternative configuration example to the analog_threshold binary sensor documentation, demonstrating how to achieve similar functionality using a template binary sensor with condition expressions.

Key Changes:

  • Added example showing template binary sensor with sensor.in_range condition as an alternative to the analog_threshold component

Comment on lines 43 to 45
id: engine_running
condition:
sensor.in_range:
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

The alternative example is incomplete and may confuse users. It's missing the required sensor_id parameter for the sensor.in_range condition to specify which sensor to monitor. Consider adding this parameter and optionally the name field to make the example more complete and parallel to the original example above.

Suggested change
id: engine_running
condition:
sensor.in_range:
id: engine_running
name: "Engine Running"
condition:
sensor.in_range:
sensor_id: motor_current_sensor

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

Fixed: f8676ba

threshold: 0.5
```
As an alternative to using this component you may use {{< docref "components/binary_sensor/template" >}} with [condition expressions](#config-condition):
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

The anchor link #config-condition appears to be invalid as there is no corresponding section with that ID in this document. Either remove the anchor or link to the correct documentation page where condition expressions are explained.

Suggested change
As an alternative to using this component you may use {{< docref "components/binary_sensor/template" >}} with [condition expressions](#config-condition):
As an alternative to using this component you may use {{< docref "components/binary_sensor/template" >}} with [condition expressions](https://esphome.io/components/binary_sensor/template.html#condition):

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

I've tested it and it still works. This way of referencing this document is used in many places.

@mik-laj
Copy link
Author

mik-laj commented Oct 16, 2025

@esphome it is not true. It is not related to new feature.

@netlify
Copy link

netlify bot commented Oct 16, 2025

Deploy Preview for esphome ready!

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

Updated the configuration for the binary sensor to include a name and corrected the condition sensor ID.
esphome[bot]
esphome bot previously requested changes Oct 16, 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.

@mik-laj mik-laj marked this pull request as ready for review October 16, 2025 17:40
@esphome esphome bot dismissed stale reviews from themself October 16, 2025 17:41

Base branch has been corrected - dismissing previous review.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds an alternative documentation example for the analog_threshold binary_sensor showing a template-based binary_sensor using sensor.in_range with a full YAML example.

Changes

Cohort / File(s) Summary
Documentation: Analog Threshold — Template Alternative
content/components/binary_sensor/analog_threshold.md
Adds a template-based binary_sensor example using a sensor.in_range condition (full YAML) as an alternative to the existing analog_threshold configuration example.

Sequence Diagram(s)

(omitted — documentation-only change, no control-flow modifications)

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the primary change by stating that the analog_threshold.md documentation is being enhanced with an alternative example. It directly reflects the content and is both clear and focused.
Description Check ✅ Passed The description clearly states that an alternative usage example for binary sensor configuration is being added and explains the context of the condition parameter feature. It directly relates to the changes in analog_threshold.md and is therefore on-topic.
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 f8676ba and ea13a7c.

📒 Files selected for processing (1)
  • content/components/binary_sensor/analog_threshold.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • content/components/binary_sensor/analog_threshold.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 2a59196 and f8676ba.

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

⚙️ CodeRabbit configuration file

  • Do not generate or add any sequence diagrams

Files:

  • content/components/binary_sensor/analog_threshold.md

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