Skip to content

Conversation

@96liuzhixin
Copy link

Description:

This is the documentation for the new DFRobot C4001 Radar Sensor component for ESPHome.

Related issue (if applicable): N/A

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

Checklist:

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 DFROBOT_C4001
    @esphomebot generate image DFRobot_C4001

  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

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
Copy link

esphome bot commented Sep 12, 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.

@esphome esphome bot marked this pull request as draft September 12, 2025 07:30
@netlify
Copy link

netlify bot commented Sep 12, 2025

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit ffff3ee
🔍 Latest deploy log https://app.netlify.com/projects/esphome/deploys/68c766fa404c060008b5f885
😎 Deploy Preview https://deploy-preview-5349--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 Sep 12, 2025

Walkthrough

A new documentation file was added describing the DFRobot C4001 radar sensor ESPHome integration with a complete example configuration using UART, external_components, dfrobot_c4001, and platform entities (select, number, switch, sensor, binary_sensor).

Changes

Cohort / File(s) Summary
Docs: DFRobot C4001 integration
content/components/dfrobot_c4001.md
Added documentation detailing ESPHome setup for DFRobot C4001, including UART bus, external_components (Git ref: dev), dfrobot_c4001 config, and platform entities: operating_mode (select), multiple numbers (ranges/sensitivity/delays), motion switch, speed/distance sensors, and presence binary sensor.

Sequence Diagram(s)

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested labels

current

Suggested reviewers

  • jesserockz

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "add c4001 sensor" succinctly and accurately reflects the primary change—adding documentation for the DFRobot C4001 sensor—so it is concise and directly related to the changeset.
Description Check ✅ Passed The description clearly states this is documentation for the DFRobot C4001 Radar Sensor, cites the related esphome PR, includes the merge checklist and image-generation instructions, and therefore is directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
🧪 Generate unit tests
  • 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.

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: 6

Caution

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

⚠️ Outside diff range comments (1)
content/components/dfrobot_c4001.md (1)

66-70: Close the fenced YAML code block.

The example code block isn’t closed, which will break page rendering.

Apply this diff:

   - platform: dfrobot_c4001
     exist_state:
       name: "Presence"
+```
🧹 Nitpick comments (2)
content/components/dfrobot_c4001.md (2)

9-14: UART0 pins (GPIO1/GPIO3) conflict with serial logging; add logger override or use alternate pins.

Using TX0/RX0 will collide with the default logger. Either disable UART logging or document alternate pins/UART.

Apply this addition to avoid conflicts:

 uart:
   id: uart_bus
   tx_pin: GPIO1
   rx_pin: GPIO3
   baud_rate: 9600
+
+logger:
+  baud_rate: 0  # Disable UART0 logging when using GPIO1/GPIO3

Alternatively, switch to a different UART and pins appropriate for the target board.


28-49: Unify entity display names (Title Case) for polish.

Small copy edits improve consistency across docs.

Optional edits:

-      name: "Mode Select"
+      name: "Operating Mode"
-      name: "Max detection distance"
+      name: "Max Detection Distance"
-      name: "Trigger range"
+      name: "Trigger Range"
-      name: "Keep sensitivity"
+      name: "Keep Sensitivity"
-      name: "Trigger sensitivity"
+      name: "Trigger Sensitivity"
-      name: "Confirm delay"
+      name: "Confirmation Delay"
-      name: "Disappear delay"
+      name: "Disappear Delay"
-      name: "Threshold factor"
+      name: "Threshold Factor"
-      name: "Min detection distance"
+      name: "Min Detection Distance"
-      name: "Motion Switch"
+      name: "Motion"

Also applies to: 52-55, 56-69

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbaafd4 and 699444b.

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

⚙️ CodeRabbit configuration file

  • Do not generate or add any sequence diagrams

Files:

  • content/components/dfrobot_c4001.md

Comment on lines +15 to +22
external_components:
- source:
type: git
url: https://github.com/96liuzhixin/esphome
ref: dev
components:
dfrobot_c4001

Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Fix YAML list for external_components; pin to a commit or remove before publish.

  • components must be a list.
  • For published docs, avoid pointing to personal forks. Either remove external_components (once the component is merged) or pin ref to a specific commit for reproducibility.

Apply this minimal fix now:

 external_components:
   - source:
       type: git
       url: https://github.com/96liuzhixin/esphome
       ref: dev
     components:
-      dfrobot_c4001
+      - dfrobot_c4001

Before merge to next, please:

  • Remove the entire external_components block, or
  • Change ref: dev to a specific commit SHA.

Fix YAML list for external_components; pin to a commit or remove before publish.

File: content/components/dfrobot_c4001.md (lines ~15-22)

  • components must be a YAML list; apply the diff below.
 external_components:
   - source:
       type: git
       url: https://github.com/96liuzhixin/esphome
       ref: dev
     components:
-      dfrobot_c4001
+      - dfrobot_c4001
  • For published docs, remove the external_components block once merged, or change ref: dev to a specific commit SHA (do not point to a personal fork/branch).
📝 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
external_components:
- source:
type: git
url: https://github.com/96liuzhixin/esphome
ref: dev
components:
dfrobot_c4001
external_components:
- source:
type: git
url: https://github.com/96liuzhixin/esphome
ref: dev
components:
- dfrobot_c4001
🤖 Prompt for AI Agents
In content/components/dfrobot_c4001.md around lines 15 to 22, the
external_components block is invalid because components is not a YAML list;
change it so components is a proper list (e.g., components: followed by a dash
entry for dfrobot_c4001), and before publishing either remove the entire
external_components block or replace ref: dev with a specific commit SHA (do not
point to a personal fork/branch).

Comment on lines +27 to +31
select:
- platform: dfrobot_c4001
operating_mode:
name: "Mode Select"

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add dfrobot_c4001_id to the select block for consistency and clarity.

Explicitly linking to the parent avoids ambiguity if multiple sensors are present.

Apply this diff:

 select:
   - platform: dfrobot_c4001
+    dfrobot_c4001_id: my_c4001
     operating_mode:
       name: "Mode Select"
📝 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
select:
- platform: dfrobot_c4001
operating_mode:
name: "Mode Select"
select:
- platform: dfrobot_c4001
dfrobot_c4001_id: my_c4001
operating_mode:
name: "Mode Select"
🤖 Prompt for AI Agents
In content/components/dfrobot_c4001.md around lines 27 to 31, the select block
lacks the dfrobot_c4001_id attribute which can cause ambiguity when multiple
sensors are present; update the select entry to include dfrobot_c4001_id
pointing to the parent sensor's id (e.g., dfrobot_c4001_id: <parent_id>) so the
select is explicitly associated with the correct sensor, preserving the existing
name and operating_mode structure.

Comment on lines +33 to +49
- platform: dfrobot_c4001
max_range:
name: "Max detection distance"
trig_range:
name: "Trigger range"
keep_sensitivity:
name: "Keep sensitivity"
trig_sensitivity:
name: "Trigger sensitivity"
confirm_delay:
name: "Confirm delay"
disappear_delay:
name: "Disappear delay"
threshold_factor:
name: "Threshold factor"
min_range:
name: "Min detection distance"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add dfrobot_c4001_id to the number block; consider exposing ranges/steps.

  • Add the component id for consistency.
  • Optionally document min/max/step for each number to guide users.

Apply this diff for the id:

 number:
   - platform: dfrobot_c4001
+    dfrobot_c4001_id: my_c4001
     max_range:
       name: "Max detection distance"

If available, please append min/max/step under each number (e.g., min: 0, max: 600, step: 1).

📝 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
- platform: dfrobot_c4001
max_range:
name: "Max detection distance"
trig_range:
name: "Trigger range"
keep_sensitivity:
name: "Keep sensitivity"
trig_sensitivity:
name: "Trigger sensitivity"
confirm_delay:
name: "Confirm delay"
disappear_delay:
name: "Disappear delay"
threshold_factor:
name: "Threshold factor"
min_range:
name: "Min detection distance"
number:
- platform: dfrobot_c4001
dfrobot_c4001_id: my_c4001
max_range:
name: "Max detection distance"
trig_range:
name: "Trigger range"
keep_sensitivity:
name: "Keep sensitivity"
trig_sensitivity:
name: "Trigger sensitivity"
confirm_delay:
name: "Confirm delay"
disappear_delay:
name: "Disappear delay"
threshold_factor:
name: "Threshold factor"
min_range:
name: "Min detection distance"
🤖 Prompt for AI Agents
In content/components/dfrobot_c4001.md around lines 33 to 49, the number entity
block is missing a component id and lacks min/max/step metadata; add an id field
with value dfrobot_c4001_id directly under the platform: dfrobot_c4001 block for
consistency, and for each number entry (max_range, trig_range, keep_sensitivity,
trig_sensitivity, confirm_delay, disappear_delay, threshold_factor, min_range)
append appropriate min:, max:, and step: keys (use sensible values — e.g.,
distances 0–600 step 1, sensitivities 0–100 step 1, delays 0–60 step 1 — or
replace with correct device limits) so users see ranges and increments.

Comment on lines +52 to +55
- platform: dfrobot_c4001
motion_switch:
name: "Motion Switch"

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add dfrobot_c4001_id to the switch block.

Keep the pattern consistent across all platforms.

Apply this diff:

 switch:
   - platform: dfrobot_c4001
+    dfrobot_c4001_id: my_c4001
     motion_switch:
       name: "Motion Switch"
📝 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
- platform: dfrobot_c4001
motion_switch:
name: "Motion Switch"
- platform: dfrobot_c4001
dfrobot_c4001_id: my_c4001
motion_switch:
name: "Motion Switch"
🤖 Prompt for AI Agents
In content/components/dfrobot_c4001.md around lines 52 to 55, the switch block
is missing the dfrobot_c4001_id field which breaks consistency with other
platforms; add a dfrobot_c4001_id entry under the motion_switch block (using the
same id naming convention used elsewhere — e.g. dfrobot_c4001_id:
"<your_device_id>" or the appropriate unique identifier for this device) so the
switch includes both name and dfrobot_c4001_id matching the project's pattern.

Comment on lines +56 to +64
sensor:
- platform: dfrobot_c4001
c4001_id: my_c4001
speed:
name: "Speed"
id: c4001_speed
distance:
name: "Distance"
id: c4001_distance
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect link property: use dfrobot_c4001_id instead of c4001_id.

Platform entities should reference the parent component’s id consistently. Replace c4001_id with dfrobot_c4001_id.

Apply this diff:

 sensor:
   - platform: dfrobot_c4001
-    c4001_id: my_c4001
+    dfrobot_c4001_id: my_c4001
     speed:
       name: "Speed"
       id: c4001_speed
     distance:
       name: "Distance"
       id: c4001_distance
📝 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
sensor:
- platform: dfrobot_c4001
c4001_id: my_c4001
speed:
name: "Speed"
id: c4001_speed
distance:
name: "Distance"
id: c4001_distance
sensor:
- platform: dfrobot_c4001
dfrobot_c4001_id: my_c4001
speed:
name: "Speed"
id: c4001_speed
distance:
name: "Distance"
id: c4001_distance
🤖 Prompt for AI Agents
In content/components/dfrobot_c4001.md around lines 56 to 64, the sensor
platform example uses the wrong link property name `c4001_id`; replace it with
`dfrobot_c4001_id` so platform entities reference the parent component id
consistently (update the key only, preserving the rest of the YAML structure and
values).

Comment on lines +66 to +69
binary_sensor:
- platform: dfrobot_c4001
exist_state:
name: "Presence"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add dfrobot_c4001_id to the binary_sensor block.

Aligns with other platform sections and supports multi-device configs.

Apply this diff:

 binary_sensor:
   - platform: dfrobot_c4001
+    dfrobot_c4001_id: my_c4001
     exist_state:
       name: "Presence"
📝 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
binary_sensor:
- platform: dfrobot_c4001
exist_state:
name: "Presence"
binary_sensor:
- platform: dfrobot_c4001
dfrobot_c4001_id: my_c4001
exist_state:
name: "Presence"
🤖 Prompt for AI Agents
In content/components/dfrobot_c4001.md around lines 66 to 69, the binary_sensor
example is missing the required dfrobot_c4001_id field which is needed to match
other platform examples and support multi-device configuration; update the YAML
snippet to include a dfrobot_c4001_id entry (e.g., dfrobot_c4001_id:
your_device_id) alongside the platform and exist_state:name keys so each sensor
instance can be associated with the correct device.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant