-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[valve] Move to use valve_schema(..)
instead of VALVE_SCHEMA
#8730
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
Conversation
Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration ( |
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.
Pull Request Overview
This PR replaces the global VALVE_SCHEMA with a dynamic factory function (valve_schema) for constructing valve schemas, aligning with other EntityBase types for consistency.
- Replaces VALVE_SCHEMA with a new valve_schema function in esphome/components/valve/init.py
- Adjusts setup functions and updates the template valve component to use the new valve_schema API
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
esphome/components/valve/init.py | Renames VALVE_SCHEMA to _VALVE_SCHEMA and adds the valve_schema function for schema generation |
esphome/components/template/valve/init.py | Updates CONFIG_SCHEMA to call valve.valve_schema, reflecting the new API usage |
@@ -71,7 +74,7 @@ | |||
|
|||
CONF_ON_CLOSED = "on_closed" | |||
|
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.
Consider adding an inline comment to clarify that _VALVE_SCHEMA holds the base valve schema and is intentionally marked as private. This will help future maintainers understand the purpose and usage of the underscore prefix.
# _VALVE_SCHEMA holds the base schema for valve components. It is marked as private | |
# to indicate that it is not intended for use outside this module. |
Copilot uses AI. Check for mistakes.
@@ -100,7 +103,30 @@ | |||
) | |||
|
|||
|
|||
async def setup_valve_core_(var, config): | |||
def valve_schema( |
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.
It would be beneficial to add a docstring to the valve_schema function, clearly describing the parameters, expected defaults, and the returned schema. This enhances readability and maintainability of the API.
Copilot uses AI. Check for mistakes.
What does this implement/fix?
Trying to bring all EntityBase types in line with each other
Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation (if applicable):
Test Environment
Example entry for
config.yaml
:# Example config.yaml
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: