8000 [valve] Move to use ``valve_schema(..)`` instead of ``VALVE_SCHEMA`` by jesserockz · Pull Request #8730 · esphome/esphome · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[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

Merged
merged 1 commit into from
May 9, 2025

Conversation

jesserockz
Copy link
Member

What does this implement/fix?

Trying to bring all EntityBase types in line with each other

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)
  • Code quality improvements to existing code or addition of tests
  • 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:

@Copilot Copilot AI review requested due to automatic review settings May 9, 2025 05:21
@jesserockz jesserockz requested a review from a team as a code owner May 9, 2025 05:21
@probot-esphome
Copy link
probot-esphome bot commented May 9, 2025

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

Copy link
Contributor
@Copilot Copilot AI left a 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"

Copy link
Preview
Copilot AI May 9, 2025

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.

Suggested change
# _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(
Copy link
Preview
Copilot AI May 9, 2025

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.

@kbx81 kbx81 merged commit 23fb1be into dev May 9, 2025
28 checks passed
@kbx81 kbx81 deleted the jesserockz-2025-114 branch May 9, 2025 06:14
juanboro pushed a commit to juanboro/esphome that referenced this pull request May 10, 2025
@jesserockz jesserockz mentioned this pull request May 13, 2025
@jesserockz jesserockz mentioned this pull request May 21, 2025
sa-crespo pushed a commit to sa-crespo/esphome that referenced this pull request May 26, 2025
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.

2 participants
0