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

Allow platform dependencies #6623

Merged
merged 5 commits into from
Apr 28, 2024
Merged

Conversation

kbx81
Copy link
Member

@kbx81 kbx81 commented Apr 24, 2024

What does this implement/fix?

Small PR that enables the ability to specify platform dependencies. For example:

DEPENDENCIES = ["ota.esphome"]

...would require the platform esphome be present within the ota component configuration:

ota:
  - platform: esphome

This enables more user-friendly validation errors should a required platform not be present.

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#

Test Environment

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

Example entry for config.yaml:

# Example config.yaml

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:

@kbx81 kbx81 requested a review from a team as a code owner April 24, 2024 08:05
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 27.27273% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 53.44%. Comparing base (4d8b5ed) to head (e9e2803).
Report is 481 commits behind head on dev.

Files Patch % Lines
esphome/config.py 27.27% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6623      +/-   ##
==========================================
- Coverage   53.70%   53.44%   -0.27%     
==========================================
  Files          50       50              
  Lines        9408     9554     +146     
  Branches     1654     1687      +33     
==========================================
+ Hits         5053     5106      +53     
- Misses       4056     4135      +79     
- Partials      299      313      +14     

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

@kbx81 kbx81 mentioned this pull request Apr 24, 2024
13 tasks
@kbx81 kbx81 added this to the 2024.5.0b1 milestone Apr 24, 2024
@nielsnl68
Copy link
Contributor

Nice idea @kbx81, is there a reason why you choose "esphome.ota" and not "ota.esphome"? To me the last version makes more sense to me. But maybe you have something else in mind that makes it easier to extend this later on?

@kbx81
Copy link
Member Author

kbx81 commented Apr 24, 2024

Nice idea @kbx81, is there a reason why you choose "esphome.ota" and not "ota.esphome"? To me the last version makes more sense to me. But maybe you have something else in mind that makes it easier to extend this later on?

It was sort of arbitrary -- but it seems we use this arrangement for the logger tags, so I just copied that. It's trivial to change, so if we agree we should swap platform.component for component.platform, I've got no issues with that. 😄

@kbx81
Copy link
Member Author

kbx81 commented Apr 26, 2024

I have switched it to use component.platform syntax as I generally think it makes more sense here. Also added some additional logic to better handle various types of config errors.

@kbx81 kbx81 force-pushed the allow-platform-dependencies branch from dc188d7 to 80e85ee Compare April 26, 2024 05:09
@probot-esphome probot-esphome bot removed the small-pr label Apr 26, 2024
@jesserockz jesserockz merged commit 8334934 into esphome:dev Apr 28, 2024
56 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants