Skip to content
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

Add support for AT581x component #6297

Merged
merged 16 commits into from Mar 26, 2024
Merged

Add support for AT581x component #6297

merged 16 commits into from Mar 26, 2024

Conversation

X-Ryl669
Copy link
Contributor

@X-Ryl669 X-Ryl669 commented Feb 27, 2024

What does this implement/fix?

This adds support for the AT581x 5.8GHz radar that's found in ESP32S3-BOX-3 device.
It's a very power efficient human detection device that configurable via I2C.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3646

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

# Example config.yaml
external_components:
  - source: github://pr#6297
    components: at581x
    refresh: 0s

at581x:
  id: "Waveradar"
  i2c_id: bus_a
  detection_pin: 21

binary_sensor:
  - platform: at581x
    at581x_id: "Waveradar"
    motion_detected:
      name: "Radar motion"

switch:
  - platform: at581x
    at581x_id: "Waveradar"
    rf:
      name: "Enable Radar"

i2c:
  - id: bus_a
    sda: GPIO41
    scl: GPIO40
    sda_pullup_enabled: false
    scl_pullup_enabled: false
    scan: false
    frequency: 400kHz

esphome:
  [...]
  on_boot:
    priority: 600
    then:
      - at581x.settings:
          id: "Waveradar"
          factory_reset: false
          frequency: 5800  # In MHz
          sensing_distance: 200 # 0-1023
          poweron_selfcheck_time: 2000 # in ms
          protect_time: 1000 # in ms
          trigger_base: 500  # in ms
          trigger_keep: 10000 # in ms
          stage_gain: 3 # 0-12 the higher the value the smaller the gain
          power_consumption: 70 # in µA

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@probot-esphome
Copy link

Hey there @X-Ryl669,
Thanks for submitting this pull request! Can you add yourself as a codeowner for this integration? This way we can notify you if a bug report for this integration is reported.
In __init__.py of the integration, please add:

CODEOWNERS = ["@X-Ryl669"]

And run script/build_codeowners.py

(message by NeedsCodeownersLabel)

@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.49%. Comparing base (4d8b5ed) to head (00b1979).
Report is 254 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6297      +/-   ##
==========================================
- Coverage   53.70%   53.49%   -0.22%     
==========================================
  Files          50       50              
  Lines        9408     9524     +116     
  Branches     1654     1685      +31     
==========================================
+ Hits         5053     5095      +42     
- Misses       4056     4120      +64     
- Partials      299      309      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@probot-esphome
Copy link

Hey there @niklasweber, mind taking a look at this pull request as it has been labeled with an integration (dfrobot_sen0395) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@probot-esphome
Copy link

Hey there @regevbr, @sebcaps, mind taking a look at this pull request as it has been labeled with an integration (ld2410) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@probot-esphome
Copy link

Hey there @descipher, mind taking a look at this pull request as it has been labeled with an integration (ld2420) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@X-Ryl669
Copy link
Contributor Author

The failing CI test is completely random (and unrelated to the code). I think it's a CI failure

@X-Ryl669 X-Ryl669 force-pushed the at581x branch 3 times, most recently from fe1a486 to 1759822 Compare March 16, 2024 18:49
@X-Ryl669 X-Ryl669 marked this pull request as draft March 16, 2024 20:08
@X-Ryl669 X-Ryl669 marked this pull request as ready for review March 17, 2024 09:52
@esphome esphome bot requested a review from jesserockz March 17, 2024 09:52
Copy link
Member

@jesserockz jesserockz left a comment

Choose a reason for hiding this comment

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

After reviewing the code and how it actually works, I don't think this entire component needs its own binary_sensor platform and the detection_pin config item.

Setting up the main component, and settings and power switch is fine, but for detecting motion, the user can just set up a gpio binary sensor on that pin.

esphome/components/at581x/at581x.cpp Outdated Show resolved Hide resolved
@esphome esphome bot marked this pull request as draft March 25, 2024 22:26
@X-Ryl669 X-Ryl669 force-pushed the at581x branch 4 times, most recently from 8949e23 to 1fd4c6b Compare March 26, 2024 07:00
@X-Ryl669 X-Ryl669 marked this pull request as ready for review March 26, 2024 07:21
@esphome esphome bot requested a review from jesserockz March 26, 2024 07:21
Copy link
Member

@jesserockz jesserockz left a comment

Choose a reason for hiding this comment

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

Thanks for making that change.

@jesserockz jesserockz merged commit 952ccf5 into esphome:dev Mar 26, 2024
54 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2024
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.

None yet

3 participants