- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.1k
 
add c4001 sensor #5349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: current
Are you sure you want to change the base?
add c4001 sensor #5349
Conversation
There was a problem hiding this 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.
| 
          
 Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍  | 
    
          ✅ Deploy Preview for esphome ready!
 To edit notification comments on pull requests, go to your Netlify project configuration.  | 
    
          
WalkthroughA 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
 Sequence Diagram(s)Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested labels
 Suggested reviewers
 Pre-merge checks (3 passed)✅ Passed checks (3 passed)
 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. 
 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
 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. Comment   | 
    
There was a problem hiding this 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/GPIO3Alternatively, 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
📒 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
| external_components: | ||
| - source: | ||
| type: git | ||
| url: https://github.com/96liuzhixin/esphome | ||
| ref: dev | ||
| components: | ||
| dfrobot_c4001 | ||
| 
               | 
          
There was a problem hiding this comment.
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.
componentsmust be a list.- For published docs, avoid pointing to personal forks. Either remove 
external_components(once the component is merged) or pinrefto 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_c4001Before merge to next, please:
- Remove the entire 
external_componentsblock, or - Change 
ref: devto 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)
componentsmust 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_componentsblock once merged, or changeref: devto 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.
| 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).
| select: | ||
| - platform: dfrobot_c4001 | ||
| operating_mode: | ||
| name: "Mode Select" | ||
| 
               | 
          
There was a problem hiding this comment.
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.
| 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.
| - 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" | 
There was a problem hiding this comment.
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.
| - 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.
| - platform: dfrobot_c4001 | ||
| motion_switch: | ||
| name: "Motion Switch" | ||
| 
               | 
          
There was a problem hiding this comment.
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.
| - 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.
| sensor: | ||
| - platform: dfrobot_c4001 | ||
| c4001_id: my_c4001 | ||
| speed: | ||
| name: "Speed" | ||
| id: c4001_speed | ||
| distance: | ||
| name: "Distance" | ||
| id: c4001_distance | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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).
| binary_sensor: | ||
| - platform: dfrobot_c4001 | ||
| exist_state: | ||
| name: "Presence" | 
There was a problem hiding this comment.
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.
| 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.
There was a problem hiding this 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.
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:
I am merging into
nextbecause this is new documentation that has a matching pull-request in esphome as linked above.Link added in
/components/index.rstfor this new component.my https://github.com/96liuzhixin/esphome
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:
Comment on this pull request with the following command, replacing
COMPONENT_NAMEwith your component name in DFROBOT_C4001@esphomebot generate image DFRobot_C4001
The ESPHome bot will respond with a downloadable ZIP file containing the SVG image.
Extract the SVG file and place it in the
images/folder of this repository.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